Skip to content

Commit f91668b

Browse files
thephezclaude
andcommitted
feat: enable Platform address state transitions
Remove the 'disabled' flags gating Platform address operations and update their inputs to the SDK's WIF-based key model, dropping the manual senderNonce fields. Expose the additional SDK exports (CoreScript, PlatformAddress, PoolingWasm, ensureInitialized) needed by the address handler, add asset-lock proof auth wiring for addressFundFromAssetLock, and cover the address operations with unit and e2e tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 76d73a8 commit f91668b

13 files changed

Lines changed: 726 additions & 157 deletions

‎public/AI_REFERENCE.md‎

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,8 +2976,6 @@ const result = await sdk.voting.masternodeVote({ masternodeProTxHash, votePoll,
29762976
**Address Transfer** - `addresses.transfer`
29772977
*Transfer credits between Platform addresses*
29782978

2979-
**Disabled:** Platform addresses not fully implemented in SDK
2980-
29812979
Signature: `transfer(options: wasm.AddressFundsTransferOptions): Promise<Map<string, wasm.PlatformAddressInfo>>`
29822980

29832981
Parameters:
@@ -3012,19 +3010,19 @@ Returns:
30123010

30133011
Example:
30143012
```javascript
3015-
import { PlatformAddressInput, PlatformAddressOutput, PlatformAddressSigner } from '@dashevo/evo-sdk';
3016-
const inputs = [new PlatformAddressInput({ address: senderAddress, amount })];
3017-
const outputs = [new PlatformAddressOutput({ address: recipientAddress, amount })];
3013+
import { PlatformAddressSigner, PrivateKey } from '@dashevo/evo-sdk';
30183014
const signer = new PlatformAddressSigner();
3019-
signer.addKey(privateKey);
3020-
await sdk.addresses.transfer({ inputs, outputs, signer });
3015+
const senderAddress = signer.addKey(PrivateKey.fromWIF(addressPrivateKeyWif));
3016+
const addressInfo = await sdk.addresses.get(senderAddress);
3017+
if (!addressInfo) throw new Error('Platform Address is not funded');
3018+
const input = { address: senderAddress.toBech32m(network), amount: BigInt(amount) };
3019+
const output = { address: recipientAddress, amount: BigInt(amount) };
3020+
await sdk.addresses.transfer({ inputs: [input], outputs: [output], signer });
30213021
```
30223022

30233023
**Top Up Identity from Address** - `addresses.topUpIdentity`
30243024
*Top up an identity using Platform address credits*
30253025

3026-
**Disabled:** Platform addresses not fully implemented in SDK
3027-
30283026
Signature: `topUpIdentity(options: wasm.IdentityTopUpFromAddressesOptions): Promise<wasm.IdentityTopUpFromAddressesResult>`
30293027

30303028
Parameters:
@@ -3054,19 +3052,20 @@ Returns:
30543052

30553053
Example:
30563054
```javascript
3057-
import { PlatformAddressInput, PlatformAddressSigner } from '@dashevo/evo-sdk';
30583055
const identity = await sdk.identities.fetch(identityId);
3059-
const inputs = [new PlatformAddressInput({ address: senderAddress, amount })];
3056+
if (!identity) throw new Error('Identity not found');
3057+
import { PlatformAddressSigner, PrivateKey } from '@dashevo/evo-sdk';
30603058
const signer = new PlatformAddressSigner();
3061-
signer.addKey(privateKey);
3062-
await sdk.addresses.topUpIdentity({ identity, inputs, signer });
3059+
const senderAddress = signer.addKey(PrivateKey.fromWIF(addressPrivateKeyWif));
3060+
const addressInfo = await sdk.addresses.get(senderAddress);
3061+
if (!addressInfo) throw new Error('Platform Address is not funded');
3062+
const input = { address: senderAddress.toBech32m(network), amount: BigInt(amount) };
3063+
await sdk.addresses.topUpIdentity({ identity, inputs: [input], signer });
30633064
```
30643065

30653066
**Withdraw to Core** - `addresses.withdraw`
30663067
*Withdraw Platform address credits to Dash Core*
30673068

3068-
**Disabled:** Platform addresses not fully implemented in SDK
3069-
30703069
Signature: `withdraw(options: wasm.AddressFundsWithdrawOptions): Promise<Map<string, wasm.PlatformAddressInfo>>`
30713070

30723071
Parameters:
@@ -3114,19 +3113,19 @@ Returns:
31143113

31153114
Example:
31163115
```javascript
3117-
import { CoreScript, PlatformAddressInput, PlatformAddressSigner } from '@dashevo/evo-sdk';
3118-
const inputs = [new PlatformAddressInput({ address: senderAddress, amount })];
3119-
const outputScript = CoreScript.newP2PKH(coreAddress);
3116+
import { PlatformAddressSigner, PrivateKey } from '@dashevo/evo-sdk';
31203117
const signer = new PlatformAddressSigner();
3121-
signer.addKey(privateKey);
3122-
await sdk.addresses.withdraw({ inputs, coreFeePerByte, pooling, outputScript, signer });
3118+
const senderAddress = signer.addKey(PrivateKey.fromWIF(addressPrivateKeyWif));
3119+
const addressInfo = await sdk.addresses.get(senderAddress);
3120+
if (!addressInfo) throw new Error('Platform Address is not funded');
3121+
const input = { address: senderAddress.toBech32m(network), amount: BigInt(amount) };
3122+
const outputScript = CoreScript.fromP2PKH(coreAddressHash);
3123+
await sdk.addresses.withdraw({ inputs: [input], coreFeePerByte, pooling: PoolingWasm.Never, outputScript, signer });
31233124
```
31243125

31253126
**Transfer from Identity to Address** - `addresses.transferFromIdentity`
31263127
*Transfer credits from an identity to Platform addresses*
31273128

3128-
**Disabled:** Platform addresses not fully implemented in SDK
3129-
31303129
Signature: `transferFromIdentity(options: wasm.IdentityTransferToAddressesOptions): Promise<wasm.IdentityTransferToAddressesResult>`
31313130

31323131
Parameters:
@@ -3159,9 +3158,10 @@ Returns:
31593158

31603159
Example:
31613160
```javascript
3162-
import { IdentitySigner, PlatformAddressOutput } from '@dashevo/evo-sdk';
3161+
import { IdentitySigner } from '@dashevo/evo-sdk';
31633162
const identity = await sdk.identities.fetch(identityId);
3164-
const outputs = [new PlatformAddressOutput({ address: recipientAddress, amount })];
3163+
if (!identity) throw new Error('Identity not found');
3164+
const outputs = [{ address: recipientAddress, amount: BigInt(amount) }];
31653165
const signer = new IdentitySigner();
31663166
signer.addKeyFromWif(privateKeyWif);
31673167
await sdk.addresses.transferFromIdentity({ identity, outputs, signer });
@@ -3170,8 +3170,6 @@ await sdk.addresses.transferFromIdentity({ identity, outputs, signer });
31703170
**Fund Address from Asset Lock** - `addresses.fundFromAssetLock`
31713171
*Fund Platform addresses from an asset lock*
31723172

3173-
**Disabled:** Platform addresses not fully implemented in SDK
3174-
31753173
Signature: `fundFromAssetLock(options: wasm.AddressFundingFromAssetLockOptions): Promise<Map<string, wasm.PlatformAddressInfo>>`
31763174

31773175
Parameters:
@@ -3210,19 +3208,18 @@ Returns:
32103208

32113209
Example:
32123210
```javascript
3213-
import { AssetLockProof, PlatformAddressOutput, PlatformAddressSigner, PrivateKey } from '@dashevo/evo-sdk';
3211+
import { AssetLockProof, PlatformAddressSigner, PrivateKey } from '@dashevo/evo-sdk';
32143212
const assetLockProof = AssetLockProof.fromHex(assetLockProofHex);
32153213
const assetLockPrivateKey = PrivateKey.fromWIF(assetLockPrivateKeyWif);
3216-
const outputs = [new PlatformAddressOutput({ address: recipientAddress, amount })];
32173214
const signer = new PlatformAddressSigner();
3215+
signer.addKey(PrivateKey.fromWIF(addressPrivateKeyWif));
3216+
const outputs = [{ address: recipientAddress, amount: BigInt(amount) }];
32183217
await sdk.addresses.fundFromAssetLock({ assetLockProof, assetLockPrivateKey, outputs, signer });
32193218
```
32203219

32213220
**Create Identity from Address** - `addresses.createIdentity`
32223221
*Create a new identity funded from Platform addresses*
32233222

3224-
**Disabled:** Platform addresses not fully implemented in SDK
3225-
32263223
Signature: `createIdentity(options: wasm.IdentityCreateFromAddressesOptions): Promise<wasm.IdentityCreateFromAddressesResult>`
32273224

32283225
Parameters:
@@ -3261,16 +3258,16 @@ Returns:
32613258

32623259
Example:
32633260
```javascript
3264-
import { Identifier, Identity, IdentityPublicKeyInCreation, IdentitySigner, KeyType, PlatformAddressInput, PlatformAddressSigner, PrivateKey, Purpose, SecurityLevel } from '@dashevo/evo-sdk';
3261+
import { Identifier, Identity, IdentityPublicKeyInCreation, IdentitySigner, KeyType, PlatformAddressSigner, PrivateKey, Purpose, SecurityLevel } from '@dashevo/evo-sdk';
32653262
const identityPrivateKey = PrivateKey.fromWIF(identityPrivateKeyWif);
3266-
const identity = new Identity(Identifier.random());
3263+
const identity = new Identity(Identifier.fromBytes(crypto.getRandomValues(new Uint8Array(32))));
32673264
const identityPublicKey = new IdentityPublicKeyInCreation({ keyId: 0, purpose: Purpose.AUTHENTICATION, securityLevel: SecurityLevel.MASTER, keyType: KeyType.ECDSA_SECP256K1, data: identityPrivateKey.getPublicKey().toBytes() }).toIdentityPublicKey();
32683265
identity.addPublicKey(identityPublicKey);
3269-
const inputs = [new PlatformAddressInput({ address: senderAddress, amount })];
3266+
const addressSigner = new PlatformAddressSigner();
3267+
const derivedAddress = addressSigner.addKey(PrivateKey.fromWIF(addressPrivateKeyWif));
3268+
const inputs = [{ address: derivedAddress.toBech32m(network), amount: BigInt(amount) }];
32703269
const identitySigner = new IdentitySigner();
32713270
identitySigner.addKey(identityPrivateKey);
3272-
const addressSigner = new PlatformAddressSigner();
3273-
addressSigner.addKey(addressPrivateKey);
32743271
await sdk.addresses.createIdentity({ identity, inputs, identitySigner, addressSigner });
32753272
```
32763273

‎public/api-definitions.json‎

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,6 @@
23852385
"addressTransfer": {
23862386
"label": "Address Transfer",
23872387
"description": "Transfer credits between Platform addresses",
2388-
"disabled": "Platform addresses not fully implemented in SDK",
23892388
"inputs": [
23902389
{
23912390
"name": "senderAddress",
@@ -2394,13 +2393,6 @@
23942393
"required": true,
23952394
"placeholder": "tdash1krt0z5hrcaphyuraxmk2h2ff8nyv5fmncsgf7evf"
23962395
},
2397-
{
2398-
"name": "senderNonce",
2399-
"type": "number",
2400-
"label": "Sender Nonce",
2401-
"required": true,
2402-
"placeholder": "0"
2403-
},
24042396
{
24052397
"name": "amount",
24062398
"type": "text",
@@ -2420,7 +2412,6 @@
24202412
"addressTopUpIdentity": {
24212413
"label": "Top Up Identity from Address",
24222414
"description": "Top up an identity using Platform address credits",
2423-
"disabled": "Platform addresses not fully implemented in SDK",
24242415
"inputs": [
24252416
{
24262417
"name": "identityId",
@@ -2436,13 +2427,6 @@
24362427
"required": true,
24372428
"placeholder": "tdash1krt0z5hrcaphyuraxmk2h2ff8nyv5fmncsgf7evf"
24382429
},
2439-
{
2440-
"name": "senderNonce",
2441-
"type": "number",
2442-
"label": "Sender Nonce",
2443-
"required": true,
2444-
"placeholder": "0"
2445-
},
24462430
{
24472431
"name": "amount",
24482432
"type": "text",
@@ -2455,7 +2439,6 @@
24552439
"addressWithdraw": {
24562440
"label": "Withdraw to Core",
24572441
"description": "Withdraw Platform address credits to Dash Core",
2458-
"disabled": "Platform addresses not fully implemented in SDK",
24592442
"inputs": [
24602443
{
24612444
"name": "senderAddress",
@@ -2464,13 +2447,6 @@
24642447
"required": true,
24652448
"placeholder": "tdash1krt0z5hrcaphyuraxmk2h2ff8nyv5fmncsgf7evf"
24662449
},
2467-
{
2468-
"name": "senderNonce",
2469-
"type": "number",
2470-
"label": "Sender Nonce",
2471-
"required": true,
2472-
"placeholder": "0"
2473-
},
24742450
{
24752451
"name": "amount",
24762452
"type": "text",
@@ -2497,7 +2473,6 @@
24972473
"addressTransferFromIdentity": {
24982474
"label": "Transfer from Identity to Address",
24992475
"description": "Transfer credits from an identity to Platform addresses",
2500-
"disabled": "Platform addresses not fully implemented in SDK",
25012476
"inputs": [
25022477
{
25032478
"name": "recipientAddress",
@@ -2518,8 +2493,13 @@
25182493
"addressFundFromAssetLock": {
25192494
"label": "Fund Address from Asset Lock",
25202495
"description": "Fund Platform addresses from an asset lock",
2521-
"disabled": "Platform addresses not fully implemented in SDK",
25222496
"inputs": [
2497+
{
2498+
"name": "addressPrivateKeyWif",
2499+
"type": "text",
2500+
"label": "Recipient Platform Address Private Key (WIF)",
2501+
"required": true
2502+
},
25232503
{
25242504
"name": "recipientAddress",
25252505
"type": "text",
@@ -2539,7 +2519,6 @@
25392519
"addressCreateIdentity": {
25402520
"label": "Create Identity from Address",
25412521
"description": "Create a new identity funded from Platform addresses",
2542-
"disabled": "Platform addresses not fully implemented in SDK",
25432522
"inputs": [
25442523
{
25452524
"name": "senderAddress",
@@ -2548,25 +2527,18 @@
25482527
"required": true,
25492528
"placeholder": "tdash1krt0z5hrcaphyuraxmk2h2ff8nyv5fmncsgf7evf"
25502529
},
2551-
{
2552-
"name": "senderNonce",
2553-
"type": "number",
2554-
"label": "Sender Nonce",
2555-
"required": true,
2556-
"placeholder": "0"
2557-
},
25582530
{
25592531
"name": "amount",
25602532
"type": "text",
25612533
"label": "Amount (credits)",
25622534
"required": true
25632535
},
25642536
{
2565-
"name": "publicKeys",
2566-
"type": "json",
2567-
"label": "Public Keys (JSON)",
2537+
"name": "identityPrivateKeyWif",
2538+
"type": "text",
2539+
"label": "New Identity Private Key (WIF)",
25682540
"required": true,
2569-
"placeholder": "[{\"id\":0,\"type\":0,\"purpose\":0,\"securityLevel\":0,\"data\":\"...\"}]"
2541+
"placeholder": "c..."
25702542
}
25712543
],
25722544
"sdk_method": "addresses.createIdentity"

‎public/sdk-operation-catalog.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4645,7 +4645,7 @@
46454645
"sdkMethod": "addresses.transfer",
46464646
"label": "Address Transfer",
46474647
"description": "Transfer credits between Platform addresses",
4648-
"disabled": "Platform addresses not fully implemented in SDK",
4648+
"disabled": null,
46494649
"signature": "transfer(options: wasm.AddressFundsTransferOptions): Promise<Map<string, wasm.PlatformAddressInfo>>",
46504650
"parameters": [
46514651
{
@@ -4718,7 +4718,7 @@
47184718
"sdkMethod": "addresses.topUpIdentity",
47194719
"label": "Top Up Identity from Address",
47204720
"description": "Top up an identity using Platform address credits",
4721-
"disabled": "Platform addresses not fully implemented in SDK",
4721+
"disabled": null,
47224722
"signature": "topUpIdentity(options: wasm.IdentityTopUpFromAddressesOptions): Promise<wasm.IdentityTopUpFromAddressesResult>",
47234723
"parameters": [
47244724
{
@@ -4782,7 +4782,7 @@
47824782
"sdkMethod": "addresses.withdraw",
47834783
"label": "Withdraw to Core",
47844784
"description": "Withdraw Platform address credits to Dash Core",
4785-
"disabled": "Platform addresses not fully implemented in SDK",
4785+
"disabled": null,
47864786
"signature": "withdraw(options: wasm.AddressFundsWithdrawOptions): Promise<Map<string, wasm.PlatformAddressInfo>>",
47874787
"parameters": [
47884788
{
@@ -4880,7 +4880,7 @@
48804880
"sdkMethod": "addresses.transferFromIdentity",
48814881
"label": "Transfer from Identity to Address",
48824882
"description": "Transfer credits from an identity to Platform addresses",
4883-
"disabled": "Platform addresses not fully implemented in SDK",
4883+
"disabled": null,
48844884
"signature": "transferFromIdentity(options: wasm.IdentityTransferToAddressesOptions): Promise<wasm.IdentityTransferToAddressesResult>",
48854885
"parameters": [
48864886
{
@@ -4951,7 +4951,7 @@
49514951
"sdkMethod": "addresses.fundFromAssetLock",
49524952
"label": "Fund Address from Asset Lock",
49534953
"description": "Fund Platform addresses from an asset lock",
4954-
"disabled": "Platform addresses not fully implemented in SDK",
4954+
"disabled": null,
49554955
"signature": "fundFromAssetLock(options: wasm.AddressFundingFromAssetLockOptions): Promise<Map<string, wasm.PlatformAddressInfo>>",
49564956
"parameters": [
49574957
{
@@ -5033,7 +5033,7 @@
50335033
"sdkMethod": "addresses.createIdentity",
50345034
"label": "Create Identity from Address",
50355035
"description": "Create a new identity funded from Platform addresses",
5036-
"disabled": "Platform addresses not fully implemented in SDK",
5036+
"disabled": null,
50375037
"signature": "createIdentity(options: wasm.IdentityCreateFromAddressesOptions): Promise<wasm.IdentityCreateFromAddressesResult>",
50385038
"parameters": [
50395039
{

‎public/src/definitions-data.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,27 +264,28 @@ export const TRANSITION_AUTH_REQUIREMENTS = {
264264
// Platform Address transitions
265265
addressTransfer: {
266266
identity: { required: false },
267-
privateKey: { required: true, targets: ['privateKeyWif'] },
267+
privateKey: { required: true, targets: ['addressPrivateKeyWif'] },
268268
},
269269
addressTopUpIdentity: {
270270
identity: { required: false },
271-
privateKey: { required: true, targets: ['privateKeyWif'] },
271+
privateKey: { required: true, targets: ['addressPrivateKeyWif'] },
272272
},
273273
addressWithdraw: {
274274
identity: { required: false },
275-
privateKey: { required: true, targets: ['privateKeyWif'] },
275+
privateKey: { required: true, targets: ['addressPrivateKeyWif'] },
276276
},
277277
addressTransferFromIdentity: {
278278
identity: { required: true, targets: ['identityId'] },
279279
privateKey: { required: true, targets: ['privateKeyWif'] },
280280
},
281281
addressFundFromAssetLock: {
282282
identity: { required: false },
283+
assetLockProof: { required: true, target: 'assetLockProof' },
283284
privateKey: { required: true, targets: ['assetLockPrivateKeyWif'] },
284285
},
285286
addressCreateIdentity: {
286287
identity: { required: false },
287-
privateKey: { required: true, targets: ['privateKeyWif'] },
288+
privateKey: { required: true, targets: ['addressPrivateKeyWif'] },
288289
},
289290
};
290291

‎public/src/sdk-types.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
export {
22
AssetLockProof,
3+
CoreScript,
34
DataContract,
45
Document,
6+
ensureInitialized,
57
EvoSDK,
68
Identifier,
79
Identity,
810
IdentityPublicKeyInCreation,
911
IdentitySigner,
1012
KeyType,
13+
PlatformAddress,
1114
PlatformAddressSigner,
15+
PoolingWasm,
1216
PrivateKey,
1317
Purpose,
1418
SecurityLevel,

0 commit comments

Comments
 (0)