@ocap/tx-protocols 1.27.11 → 1.27.12

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.
@@ -113,7 +113,7 @@ runner.use(
113
113
  pipes.verifyTokenAccess({
114
114
  statesKey: 'tokenState',
115
115
  listFieldKey: 'minters',
116
- accountKeys: ['signerStates', 'senderState'],
116
+ accountKeys: ['senderState'],
117
117
  errorMessage: 'Account {address} is not allowed to burn token {tokenAddress}',
118
118
  })
119
119
  );
@@ -121,7 +121,7 @@ runner.use(
121
121
  pipes.verifyTokenAccess({
122
122
  statesKey: 'tokenState',
123
123
  listFieldKey: 'minters',
124
- accountKeys: ['senderState', 'receiverState', 'itx.receiver'],
124
+ accountKeys: ['senderState'],
125
125
  errorMessage: 'Account {address} is not allowed to mint token {tokenAddress}',
126
126
  })
127
127
  );
@@ -120,8 +120,29 @@ runner.use(
120
120
  ])
121
121
  );
122
122
 
123
- // 3. verify multi sig
124
- runner.use(pipes.VerifyMultiSigV2({ signersKey: 'senders' }));
123
+ // 3. Extract token states FIRST to check token type and ownership
124
+ runner.use(pipes.ExtractState({ from: 'inputTokens', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
125
+
126
+ // 3.5. Conditionally verify multi sig - skip for token owner transferring credit tokens
127
+ runner.use((context, next) => {
128
+ const { tx, inputTokens = [], tokenStates = [] } = context;
129
+
130
+ // Check if all input tokens are credit tokens and issuer is owner
131
+ const isCreditTokenFromIssuer = inputTokens.every((tokenAddress) => {
132
+ const tokenState = tokenStates.find((t) => t.address === tokenAddress);
133
+ return tokenState && tokenState.type === 'CreditToken' && tokenState.issuer === tx.from;
134
+ });
135
+
136
+ // Token owner transferring credit tokens from users
137
+ // Skip multi-sig verification for signers
138
+ if (isCreditTokenFromIssuer) {
139
+ return next();
140
+ }
141
+
142
+ // Normal transfer: verify all senders' signatures
143
+ const verifyMultiSig = pipes.VerifyMultiSigV2({ signersKey: 'senders' });
144
+ return verifyMultiSig(context, next);
145
+ });
125
146
 
126
147
  // 4. verify sender & signer & receiver
127
148
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
@@ -132,7 +153,6 @@ runner.use(pipes.AntiLandAttack({ senderState: 'signerStates', receiverState: 'r
132
153
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
133
154
 
134
155
  // 5. verify token state and balance
135
- runner.use(pipes.ExtractState({ from: 'inputTokens', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
136
156
  runner.use(pipes.VerifyTokenBalance({ ownerKey: 'signerStates', conditionKey: 'inputs' }));
137
157
  runner.use(
138
158
  pipes.verifyTokenAccess({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.27.11",
6
+ "version": "1.27.12",
7
7
  "description": "Predefined tx pipeline sets to execute certain type of transactions",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,20 +19,20 @@
19
19
  "empty-value": "^1.0.1",
20
20
  "lodash": "^4.17.21",
21
21
  "url-join": "^4.0.1",
22
- "@arcblock/did-util": "1.27.11",
23
- "@arcblock/jwt": "1.27.11",
24
- "@arcblock/vc": "1.27.11",
25
- "@ocap/asset": "1.27.11",
26
- "@ocap/client": "1.27.11",
27
- "@ocap/mcrypto": "1.27.11",
28
- "@ocap/merkle-tree": "1.27.11",
29
- "@ocap/message": "1.27.11",
30
- "@ocap/state": "1.27.11",
31
- "@arcblock/validator": "1.27.11",
32
- "@ocap/tx-pipeline": "1.27.11",
33
- "@ocap/util": "1.27.11",
34
- "@ocap/wallet": "1.27.11",
35
- "@arcblock/did": "1.27.11"
22
+ "@arcblock/did": "1.27.12",
23
+ "@arcblock/did-util": "1.27.12",
24
+ "@arcblock/jwt": "1.27.12",
25
+ "@arcblock/validator": "1.27.12",
26
+ "@arcblock/vc": "1.27.12",
27
+ "@ocap/asset": "1.27.12",
28
+ "@ocap/client": "1.27.12",
29
+ "@ocap/mcrypto": "1.27.12",
30
+ "@ocap/merkle-tree": "1.27.12",
31
+ "@ocap/message": "1.27.12",
32
+ "@ocap/state": "1.27.12",
33
+ "@ocap/tx-pipeline": "1.27.12",
34
+ "@ocap/util": "1.27.12",
35
+ "@ocap/wallet": "1.27.12"
36
36
  },
37
37
  "resolutions": {
38
38
  "bn.js": "5.2.2",
@@ -41,8 +41,8 @@
41
41
  "devDependencies": {
42
42
  "jest": "^29.7.0",
43
43
  "start-server-and-test": "^1.14.0",
44
- "@ocap/e2e-test": "1.27.11",
45
- "@ocap/statedb-memory": "1.27.11"
44
+ "@ocap/e2e-test": "1.27.12",
45
+ "@ocap/statedb-memory": "1.27.12"
46
46
  },
47
47
  "scripts": {
48
48
  "lint": "eslint tests lib",