@ocap/tx-protocols 1.18.59 → 1.18.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/lib/protocols/account/declare.js +1 -1
  2. package/lib/protocols/account/delegate.js +6 -5
  3. package/lib/protocols/account/migrate.js +2 -2
  4. package/lib/protocols/account/revoke-delegate.js +1 -1
  5. package/lib/protocols/asset/acquire-v2.js +22 -1
  6. package/lib/protocols/asset/acquire-v3.js +20 -1
  7. package/lib/protocols/asset/consume.js +15 -6
  8. package/lib/protocols/asset/create.js +1 -1
  9. package/lib/protocols/asset/mint.js +5 -3
  10. package/lib/protocols/asset/update.js +1 -1
  11. package/lib/protocols/factory/create.js +3 -2
  12. package/lib/protocols/governance/claim-stake.js +1 -1
  13. package/lib/protocols/governance/revoke-stake.js +1 -1
  14. package/lib/protocols/governance/slash-stake.js +6 -3
  15. package/lib/protocols/governance/stake.js +6 -1
  16. package/lib/protocols/rollup/claim-reward.js +1 -1
  17. package/lib/protocols/rollup/close.js +1 -1
  18. package/lib/protocols/rollup/create-block.js +3 -7
  19. package/lib/protocols/rollup/create.js +1 -1
  20. package/lib/protocols/rollup/join.js +1 -1
  21. package/lib/protocols/rollup/leave.js +1 -1
  22. package/lib/protocols/rollup/migrate.js +1 -1
  23. package/lib/protocols/rollup/pause.js +1 -1
  24. package/lib/protocols/rollup/resume.js +1 -1
  25. package/lib/protocols/rollup/update.js +1 -1
  26. package/lib/protocols/token/create.js +1 -1
  27. package/lib/protocols/token/deposit-v2.js +2 -2
  28. package/lib/protocols/token/withdraw-v2.js +1 -1
  29. package/lib/protocols/trade/exchange-v2.js +1 -1
  30. package/lib/protocols/trade/transfer-v2.js +1 -1
  31. package/lib/protocols/trade/transfer-v3.js +1 -1
  32. package/package.json +14 -14
@@ -27,7 +27,7 @@ runner.use(({ itx }, next) => {
27
27
  // Ensure sender does not exist
28
28
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState' }));
29
29
  runner.use(pipes.VerifySender({ state: 'senderState' }));
30
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
30
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
31
31
 
32
32
  // The issuer must exist in the ledger
33
33
  runner.use(pipes.ExtractState({ from: 'itx.issuer', to: 'issuerState', status: 'INVALID_TX' }));
@@ -64,12 +64,13 @@ runner.use(
64
64
  ])
65
65
  );
66
66
 
67
- // Ensure sender/receiver exist
68
- runner.use(
69
- pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
70
- );
71
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
67
+ // Ensure sender exist and not migrated
68
+ runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
69
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
70
+
71
+ // Ensure receiver exist and not migrated
72
72
  runner.use(pipes.ExtractState({ from: 'itx.to', to: 'receiverState', status: 'OK', table: 'account' }));
73
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'receiverState', addressKey: 'itx.to' }));
73
74
 
74
75
  // Extract delegation
75
76
  runner.use(pipes.ExtractState({ from: 'itx.address', to: 'delegationState', table: 'delegation', status: 'OK' }));
@@ -40,7 +40,7 @@ runner.use(
40
40
 
41
41
  // Ensure sender exist
42
42
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
43
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
43
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
44
44
 
45
45
  // Ensure tx fee and gas
46
46
  runner.use(
@@ -88,7 +88,7 @@ runner.use(
88
88
  if (address === sender.address) {
89
89
  state = account.update(sender, { migratedTo: itx.address, nonce: tx.nonce }, context);
90
90
  } else {
91
- const old = await statedb.account.get(address, { final: false, txn: context.txn });
91
+ const old = await statedb.account.get(address, { traceMigration: false, txn: context.txn });
92
92
  state = account.update(old, { migratedTo: itx.address }, context);
93
93
  }
94
94
 
@@ -60,7 +60,7 @@ runner.use(
60
60
  // Ensure sender/receiver/delegation exist
61
61
  runner.use(pipes.ExtractState({ from: 'itx.address', to: 'delegationState', status: 'INVALID_DELEGATION', table: 'delegation' })); // prettier-ignore
62
62
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
63
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
63
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
64
64
 
65
65
  // Ensure tx fee and gas
66
66
  runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
@@ -58,12 +58,33 @@ runner.use(
58
58
  );
59
59
 
60
60
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
61
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
61
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
62
62
 
63
63
  runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK' }));
64
64
  runner.use(pipes.VerifyDelegation({ type: 'signature', signerKey: 'senderState', delegatorKey: 'delegatorState' }));
65
65
 
66
66
  runner.use(pipes.ExtractState({ from: 'itx.factory', to: 'factoryState', status: 'INVALID_FACTORY_STATE', table: 'factory' })); // prettier-ignore
67
+ runner.use(pipes.ExtractState({ from: 'factoryState.owner', to: 'factoryOwnerState', status: 'INVALID_OWNER_STATE' , table: 'account'})); // prettier-ignore
68
+ runner.use(pipes.ExtractState({ from: 'factoryState.trustedIssuers', to: 'issuerStates', status: 'INVALID_ISSUER_STATE' , table: 'account'})); // prettier-ignore
69
+ runner.use(pipes.ExtractState({ from: 'itx.issuer.id', to: 'issuerState', status: 'INVALID_ISSUER_STATE', table: 'account' })); // prettier-ignore
70
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'issuerState', addressKey: 'itx.issuer.id' }));
71
+
72
+ runner.use(
73
+ pipes.VerifyInfo([
74
+ {
75
+ error: 'FORBIDDEN',
76
+ message: 'Only factory owner and trusted issuers are allowed',
77
+ fn: ({ issuerState, factoryOwnerState, issuerStates = [] }) => {
78
+ return (
79
+ factoryOwnerState.address === issuerState.address ||
80
+ issuerStates.find((x) => x.address === issuerState.address)
81
+ );
82
+ },
83
+ persist: true,
84
+ },
85
+ ])
86
+ );
87
+
67
88
  runner.use(pipes.ExtractState({ from: 'itx.assetsList', to: 'assetStates', status: 'OK', table: 'asset' }));
68
89
  runner.use(
69
90
  pipes.ExtractState({
@@ -77,6 +77,25 @@ runner.use(pipes.VerifyMultiSigV2({ signersKey: 'senders' }));
77
77
 
78
78
  // 4. verify against factory state
79
79
  runner.use(pipes.ExtractState({ from: 'itx.factory', to: 'factoryState', status: 'INVALID_FACTORY_STATE', table: 'factory' })); // prettier-ignore
80
+ runner.use(pipes.ExtractState({ from: 'factoryState.owner', to: 'factoryOwnerState', status: 'INVALID_OWNER_STATE' , table: 'account'})); // prettier-ignore
81
+ runner.use(pipes.ExtractState({ from: 'factoryState.trustedIssuers', to: 'issuerStates', status: 'INVALID_ISSUER_STATE' , table: 'account'})); // prettier-ignore
82
+ runner.use(pipes.ExtractState({ from: 'itx.issuer.id', to: 'issuerState', status: 'INVALID_ISSUER_STATE', table: 'account' })); // prettier-ignore
83
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'issuerState', addressKey: 'itx.issuer.id' }));
84
+ runner.use(
85
+ pipes.VerifyInfo([
86
+ {
87
+ error: 'FORBIDDEN',
88
+ message: 'Only factory owner and trusted issuers are allowed',
89
+ fn: ({ issuerState, factoryOwnerState, issuerStates = [] }) => {
90
+ return (
91
+ factoryOwnerState.address === issuerState.address ||
92
+ issuerStates.find((x) => x.address === issuerState.address)
93
+ );
94
+ },
95
+ persist: true,
96
+ },
97
+ ])
98
+ );
80
99
  runner.use(extractFactoryTokens);
81
100
  runner.use(verifyMintLimit);
82
101
  runner.use(verifyItxVariables);
@@ -117,7 +136,7 @@ runner.use(
117
136
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' })); // prettier-ignore
118
137
  runner.use(pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
119
138
  runner.use(pipes.ExtractState({ from: 'itx.owner', to: 'ownerState', status: 'OK', table: 'account' }));
120
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
139
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
121
140
 
122
141
  // 6. verify token state and balance
123
142
  runner.use(pipes.ExtractState({ from: 'tokens', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
@@ -31,7 +31,7 @@ runner.use(pipes.ExtractState({ from: 'itx.address', to: 'assetState', status: '
31
31
 
32
32
  // Ensure asset can be consumed
33
33
  runner.use((context, next) => {
34
- const { issuer, owner, consumedTime } = context.assetState;
34
+ const { issuer, consumedTime } = context.assetState;
35
35
  if (!issuer) {
36
36
  return next(new Error('INVALID_TX', 'Asset without issuer can not be consumed'));
37
37
  }
@@ -39,16 +39,25 @@ runner.use((context, next) => {
39
39
  return next(new Error('INVALID_TX', `Asset already consumed on ${consumedTime}`));
40
40
  }
41
41
 
42
- context.signers = [owner, issuer];
43
42
  return next();
44
43
  });
45
44
 
46
- // Ensure owner and issuer signed
47
- runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
48
-
49
45
  // Ensure sender exist
50
46
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
51
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
47
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
48
+
49
+ // Ensure owner/issuer exist
50
+ runner.use(pipes.ExtractState({ from: 'assetState.issuer', to: 'issuerState', status: 'INVALID_ISSUER_STATE', table: 'account' })); // prettier-ignore
51
+ runner.use(pipes.ExtractState({ from: 'assetState.owner', to: 'ownerState', status: 'INVALID_OWNER_STATE', table: 'account' })); // prettier-ignore
52
+ runner.use((context, next) => {
53
+ context.signerStates = [context.ownerState, context.issuerState];
54
+ context.signers = [context.ownerState.address, context.issuerState.address];
55
+ return next();
56
+ });
57
+
58
+ // Ensure owner and issuer signed: and not migrated
59
+ runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
60
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates' }));
52
61
 
53
62
  // Ensure tx fee and gas
54
63
  runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
@@ -66,7 +66,7 @@ runner.use(pipes.VerifyAccountMigration({ signerKey: 'issuerState' }));
66
66
 
67
67
  // Ensure sender exist
68
68
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
69
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
69
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
70
70
 
71
71
  // Ensure delegation
72
72
  runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK', table: 'account' }));
@@ -51,10 +51,11 @@ runner.use(
51
51
 
52
52
  // Ensure sender exist
53
53
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
54
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
54
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
55
55
 
56
56
  // Ensure factory exist
57
57
  runner.use(pipes.ExtractState({ from: 'itx.factory', to: 'factoryState', status: 'INVALID_FACTORY_STATE', table: 'factory' })); // prettier-ignore
58
+ runner.use(pipes.ExtractState({ from: 'factoryState.owner', to: 'factoryOwnerState', status: 'INVALID_ISSUER_STATE' , table: 'account'})); // prettier-ignore
58
59
 
59
60
  // Ensure issuer exist: read them here because some maybe migrated
60
61
  runner.use(pipes.ExtractState({ from: 'factoryState.trustedIssuers', to: 'issuerStates', status: 'INVALID_ISSUER_STATE' , table: 'account'})); // prettier-ignore
@@ -66,8 +67,9 @@ runner.use(
66
67
  {
67
68
  error: 'FORBIDDEN',
68
69
  message: 'Only factory owner and trusted issuers are allowed to mint',
69
- fn: ({ factoryState, senderState, issuerStates }) =>
70
- senderState.address === factoryState.owner || issuerStates.find((x) => x.address === senderState.address),
70
+ fn: ({ factoryOwnerState, senderState, issuerStates }) =>
71
+ senderState.address === factoryOwnerState.address ||
72
+ issuerStates.find((x) => x.address === senderState.address),
71
73
  persist: true,
72
74
  },
73
75
  ])
@@ -42,7 +42,7 @@ runner.use(pipes.ExtractState({ from: 'assetState.issuer', to: 'issuerState', st
42
42
 
43
43
  // Ensure sender exist
44
44
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
45
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
45
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
46
46
 
47
47
  // Ensure asset owned by sender and can be modified
48
48
  runner.use(pipes.VerifyUpdater({ assetKey: 'assetState', ownerKey: 'senderState', updaterKey: ['owner', 'issuer'] }));
@@ -82,7 +82,7 @@ runner.use(
82
82
 
83
83
  // Ensure sender exist
84
84
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', table: 'account', status: 'INVALID_SENDER_STATE' })); // prettier-ignore
85
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
85
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
86
86
 
87
87
  // Ensure delegation
88
88
  runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK', table: 'account' }));
@@ -107,8 +107,9 @@ runner.use((context, next) => {
107
107
  return next(new Error('INVALID_FACTORY_INPUT', 'Not all input.assets exist on chain'));
108
108
  });
109
109
 
110
- // ensure issuer exists
110
+ // ensure issuer exists and not migrated
111
111
  runner.use(pipes.ExtractState({ from: 'factoryProps.trustedIssuers', to: 'issuerStates', table: 'account', status: 'INVALID_ISSUER_STATE' })); // prettier-ignore
112
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'issuerStates', addressKey: 'factoryProps.trustedIssuers' }));
112
113
 
113
114
  // Ensure tx fee and gas
114
115
  runner.use(EnsureTxGas(() => ({ create: 1, update: 1, payment: 0 })));
@@ -32,7 +32,7 @@ runner.use(({ itx }, next) => {
32
32
  // 2. verify stake state & sender state
33
33
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
34
34
  runner.use(pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })); // prettier-ignore
35
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
35
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
36
36
  runner.use(
37
37
  pipes.VerifyInfo([
38
38
  {
@@ -56,7 +56,7 @@ runner.use(pipes.VerifyListSize({ listKey: ['outputs', 'receivers', 'tokens', 'a
56
56
  // 4. verify sender & receiver
57
57
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
58
58
  runner.use(pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'INVALID_RECEIVER_STATE', table: 'account' })); // prettier-ignore
59
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
59
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
60
60
 
61
61
  // 5. verify stake state
62
62
  runner.use(pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })); // prettier-ignore
@@ -62,17 +62,20 @@ runner.use(pipes.VerifyListSize({ listKey: ['outputs', 'receivers', 'tokens', 'a
62
62
  // 4. verify sender & receiver
63
63
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
64
64
  runner.use(pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'INVALID_RECEIVER_STATE', table: 'account' })); // prettier-ignore
65
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
65
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
66
66
 
67
67
  // 5. verify stake state
68
68
  runner.use(pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })); // prettier-ignore
69
+ runner.use(pipes.ExtractState({ from: 'stakeState.slashers', to: 'slasherStates', status: 'INVALID_SLASH_STATE', table: 'account' })); // prettier-ignore
69
70
  runner.use(
70
71
  pipes.VerifyInfo([
71
72
  {
72
73
  error: 'INVALID_TX',
73
74
  message: 'You are not allowed to slash from this stake',
74
- fn: ({ tx, stakeState }) =>
75
- (isEmpty(stakeState.slashers) ? [stakeState.receiver] : stakeState.slashers).includes(tx.from),
75
+ fn: ({ senderState, stakeState, slasherStates = [] }) =>
76
+ (isEmpty(slasherStates) ? [stakeState.receiver] : slasherStates.map((x) => x.address)).includes(
77
+ senderState.address
78
+ ),
76
79
  },
77
80
  ])
78
81
  );
@@ -77,8 +77,9 @@ runner.use(pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: '
77
77
  // 5. verify sender & signer & receiver
78
78
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
79
79
  runner.use(pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
80
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
80
81
  runner.use(pipes.ExtractState({ from: 'itx.receiver', to: 'receiverState', status: 'INVALID_RECEIVER_STATE' })); // can by any type
81
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
82
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'receiverState', addressKey: 'itx.receiver' }));
82
83
 
83
84
  // 6. verify token state and balance
84
85
  runner.use(pipes.ExtractState({ from: 'tokens', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
@@ -105,6 +106,10 @@ runner.use(async (context, next) => {
105
106
  return next();
106
107
  });
107
108
 
109
+ // ensure slashers exist and not migrated
110
+ runner.use(pipes.ExtractState({ from: 'itx.slashersList', to: 'slasherStates', status: 'INVALID_SLASHER_STATE', table: 'account' })); // prettier-ignore
111
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'slasherStates', addressKey: 'itx.slashersList' }));
112
+
108
113
  // 8. handle tx gas stakes
109
114
  runner.use(async (context, next) => {
110
115
  const { tx, itx, inputs, config } = context;
@@ -97,7 +97,7 @@ runner.use(pipes.ExtractState({ from: 'producerStake', to: 'stakeState', status:
97
97
  // 6. verify sender and signer states
98
98
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
99
99
  runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
100
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
100
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
101
101
 
102
102
  // 7. verify token state
103
103
  runner.use(pipes.ExtractState({ from: 'rollupState.tokenAddress', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' })); // prettier-ignore
@@ -39,7 +39,7 @@ runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
39
39
  // 4. verify sender and signer states
40
40
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
41
41
  runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
42
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
42
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
43
43
 
44
44
  // 5. extract validator stake stakes
45
45
  runner.use((context, next) => {
@@ -134,13 +134,9 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
134
134
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
135
135
 
136
136
  // 4. verify sender and signer states
137
- runner.use(
138
- pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
139
- );
140
- runner.use(
141
- pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
142
- );
143
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
137
+ runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
138
+ runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
139
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
144
140
 
145
141
  // 5. verify previous block
146
142
  runner.use(pipes.ExtractState({ from: 'itx.previousHash', to: 'previousBlock', status: 'OK', table: 'rollupBlock' }));
@@ -70,7 +70,7 @@ runner.use(
70
70
  // 1. ensure sender, validators, delegation
71
71
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
72
72
  runner.use(pipes.ExtractState({ from: 'seedValidators', to: 'validatorStates', status: 'INVALID_VALIDATOR_STATE', table: 'account' })); // prettier-ignore
73
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'validatorStates', senderKey: 'senderState' }));
73
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'validatorStates', stateKey: 'senderState', addressKey: 'tx.from' })); // prettier-ignore
74
74
  runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK', table: 'account' }));
75
75
  runner.use(pipes.VerifyDelegation({ type: 'signature', signerKey: 'senderState', delegatorKey: 'delegatorState' }));
76
76
 
@@ -110,7 +110,7 @@ runner.use(
110
110
  runner.use(
111
111
  pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
112
112
  );
113
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
113
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
114
114
 
115
115
  // Ensure tx fee and gas
116
116
  runner.use(EnsureTxGas(() => ({ create: 1, update: 3, payment: 0 })));
@@ -87,7 +87,7 @@ runner.use(
87
87
  runner.use(
88
88
  pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
89
89
  );
90
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
90
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
91
91
 
92
92
  // Ensure tx fee and gas
93
93
  runner.use(EnsureTxGas(() => ({ create: 1, update: 3, payment: 0 })));
@@ -36,7 +36,7 @@ runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
36
36
  // 4. verify sender and signer states
37
37
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
38
38
  runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
39
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
39
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
40
40
 
41
41
  // Ensure tx fee and gas
42
42
  runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
@@ -33,7 +33,7 @@ runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
33
33
  // 4. verify sender and signer states
34
34
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
35
35
  runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
36
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
36
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
37
37
 
38
38
  // Ensure tx fee and gas
39
39
  runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
@@ -33,7 +33,7 @@ runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
33
33
  // 4. verify sender and signer states
34
34
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
35
35
  runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
36
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
36
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
37
37
 
38
38
  // Ensure tx fee and gas
39
39
  runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
@@ -78,7 +78,7 @@ runner.use(
78
78
  runner.use(
79
79
  pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
80
80
  );
81
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
81
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
82
82
 
83
83
  // Ensure tx fee and gas
84
84
  runner.use(EnsureTxGas(() => ({ create: 0, update: 2, payment: 0 })));
@@ -61,7 +61,7 @@ runner.use(
61
61
 
62
62
  // Ensure sender exist
63
63
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
64
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
64
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
65
65
 
66
66
  // Ensure delegation
67
67
  runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK', table: 'account' }));
@@ -158,10 +158,10 @@ runner.use((context, next) => {
158
158
  return next();
159
159
  });
160
160
 
161
- // 7. verify sender and signer states
161
+ // 7. verify sender and signer exists and not migrated
162
162
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
163
163
  runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
164
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
164
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
165
165
 
166
166
  // Ensure tx fee and gas
167
167
  runner.use(
@@ -61,7 +61,7 @@ runner.use(pipes.ExtractState({ from: 'itx.token.address', to: 'tokenState', sta
61
61
 
62
62
  // 4. verify sender and signer states
63
63
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
64
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
64
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
65
65
 
66
66
  // 5. verify amount
67
67
  runner.use((context, next) => {
@@ -105,7 +105,7 @@ runner.use(
105
105
  runner.use(pipes.ExtractState({ from: 'tokenAddress', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
106
106
 
107
107
  runner.use(pipes.ExtractState({ from: 'receiver', to: 'receiverState', status: 'INVALID_RECEIVER_STATE', table: 'account' })); // prettier-ignore
108
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState', signerKey: 'signerStates' }));
108
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
109
109
  runner.use((context, next) => {
110
110
  context.senderTokenConditions = {
111
111
  owner: context.senderState.address,
@@ -83,7 +83,7 @@ runner.use((context, next) => {
83
83
  });
84
84
 
85
85
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
86
- runner.use(pipes.VerifyAccountMigration({ senderKey: 'senderState' }));
86
+ runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
87
87
 
88
88
  runner.use(pipes.ExtractState({ from: 'tokenAddress', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
89
89
  runner.use((context, next) => {
@@ -127,7 +127,7 @@ runner.use(pipes.VerifyMultiSigV2({ signersKey: 'senders' }));
127
127
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
128
128
  runner.use(pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
129
129
  runner.use(pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'OK', table: 'account' }));
130
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', senderKey: 'senderState' }));
130
+ runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
131
131
 
132
132
  // 5. verify token state and balance
133
133
  runner.use(pipes.ExtractState({ from: 'inputTokens', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.59",
6
+ "version": "1.18.61",
7
7
  "description": "Predefined tx pipeline sets to execute certain type of transactions",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -21,18 +21,18 @@
21
21
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@arcblock/did": "1.18.59",
25
- "@arcblock/did-util": "1.18.59",
26
- "@arcblock/jwt": "1.18.59",
27
- "@arcblock/validator": "1.18.59",
28
- "@ocap/asset": "1.18.59",
29
- "@ocap/mcrypto": "1.18.59",
30
- "@ocap/merkle-tree": "1.18.59",
31
- "@ocap/message": "1.18.59",
32
- "@ocap/state": "1.18.59",
33
- "@ocap/tx-pipeline": "1.18.59",
34
- "@ocap/util": "1.18.59",
35
- "@ocap/wallet": "1.18.59",
24
+ "@arcblock/did": "1.18.61",
25
+ "@arcblock/did-util": "1.18.61",
26
+ "@arcblock/jwt": "1.18.61",
27
+ "@arcblock/validator": "1.18.61",
28
+ "@ocap/asset": "1.18.61",
29
+ "@ocap/mcrypto": "1.18.61",
30
+ "@ocap/merkle-tree": "1.18.61",
31
+ "@ocap/message": "1.18.61",
32
+ "@ocap/state": "1.18.61",
33
+ "@ocap/tx-pipeline": "1.18.61",
34
+ "@ocap/util": "1.18.61",
35
+ "@ocap/wallet": "1.18.61",
36
36
  "debug": "^4.3.4",
37
37
  "deep-diff": "^1.0.2",
38
38
  "empty-value": "^1.0.1",
@@ -47,5 +47,5 @@
47
47
  "jest": "^27.5.1",
48
48
  "start-server-and-test": "^1.14.0"
49
49
  },
50
- "gitHead": "0376830a7ee13815fc4428330418079387e1fc30"
50
+ "gitHead": "350ee5dcb48f4c335e13b59866fd1ad3f4189bfc"
51
51
  }