@ocap/tx-protocols 1.29.3 → 1.29.4
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.
|
@@ -9,6 +9,7 @@ import { BN } from "@ocap/util";
|
|
|
9
9
|
import { decodeBigInt } from "@ocap/message";
|
|
10
10
|
import { getListField } from "@ocap/util/lib/get-list-field";
|
|
11
11
|
import { Joi, schemas } from "@arcblock/validator";
|
|
12
|
+
import { getRelatedAddresses } from "@ocap/util/lib/get-related-addr";
|
|
12
13
|
import isEmpty from "lodash/isEmpty.js";
|
|
13
14
|
|
|
14
15
|
//#region src/protocols/trade/transfer-v2.ts
|
|
@@ -118,6 +119,16 @@ runner.use(pipes.VerifyTokenBalance({
|
|
|
118
119
|
ownerKey: "senderState",
|
|
119
120
|
conditionKey: "tokenConditions"
|
|
120
121
|
}));
|
|
122
|
+
runner.use(pipes.ExtractReceiver({
|
|
123
|
+
from: "itx.to",
|
|
124
|
+
to: "receiver"
|
|
125
|
+
}));
|
|
126
|
+
runner.use(pipes.ExtractState({
|
|
127
|
+
from: "receiver",
|
|
128
|
+
to: "receiverState",
|
|
129
|
+
status: "OK",
|
|
130
|
+
table: "account"
|
|
131
|
+
}));
|
|
121
132
|
runner.use(pipes.ExtractState({
|
|
122
133
|
from: "tx.delegator",
|
|
123
134
|
to: "delegatorState",
|
|
@@ -136,28 +147,19 @@ runner.use(pipes.VerifyDelegation({
|
|
|
136
147
|
const context = ctx;
|
|
137
148
|
const tokens = context.tokens || [];
|
|
138
149
|
const assets = context.assets || [];
|
|
150
|
+
const toAddresses = context.receiverState ? getRelatedAddresses(context.receiverState) : [context.itx.to];
|
|
139
151
|
return [...tokens.map((x) => ({
|
|
140
152
|
type: "token",
|
|
141
153
|
address: x.address,
|
|
142
154
|
value: x.value,
|
|
143
|
-
to:
|
|
155
|
+
to: toAddresses
|
|
144
156
|
})), ...assets.map((x) => ({
|
|
145
157
|
type: "asset",
|
|
146
158
|
address: x,
|
|
147
|
-
to:
|
|
159
|
+
to: toAddresses
|
|
148
160
|
}))];
|
|
149
161
|
}
|
|
150
162
|
}));
|
|
151
|
-
runner.use(pipes.ExtractReceiver({
|
|
152
|
-
from: "itx.to",
|
|
153
|
-
to: "receiver"
|
|
154
|
-
}));
|
|
155
|
-
runner.use(pipes.ExtractState({
|
|
156
|
-
from: "receiver",
|
|
157
|
-
to: "receiverState",
|
|
158
|
-
status: "OK",
|
|
159
|
-
table: "account"
|
|
160
|
-
}));
|
|
161
163
|
runner.use(pipes.AntiLandAttack({
|
|
162
164
|
senderState: "senderState",
|
|
163
165
|
receiverState: "receiverState"
|
|
@@ -11,6 +11,7 @@ let _ocap_util = require("@ocap/util");
|
|
|
11
11
|
let _ocap_message = require("@ocap/message");
|
|
12
12
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
13
13
|
let _arcblock_validator = require("@arcblock/validator");
|
|
14
|
+
let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr");
|
|
14
15
|
let lodash_isEmpty = require("lodash/isEmpty");
|
|
15
16
|
lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
|
|
16
17
|
|
|
@@ -121,6 +122,16 @@ runner.use(_ocap_tx_pipeline.pipes.VerifyTokenBalance({
|
|
|
121
122
|
ownerKey: "senderState",
|
|
122
123
|
conditionKey: "tokenConditions"
|
|
123
124
|
}));
|
|
125
|
+
runner.use(_ocap_tx_pipeline.pipes.ExtractReceiver({
|
|
126
|
+
from: "itx.to",
|
|
127
|
+
to: "receiver"
|
|
128
|
+
}));
|
|
129
|
+
runner.use(_ocap_tx_pipeline.pipes.ExtractState({
|
|
130
|
+
from: "receiver",
|
|
131
|
+
to: "receiverState",
|
|
132
|
+
status: "OK",
|
|
133
|
+
table: "account"
|
|
134
|
+
}));
|
|
124
135
|
runner.use(_ocap_tx_pipeline.pipes.ExtractState({
|
|
125
136
|
from: "tx.delegator",
|
|
126
137
|
to: "delegatorState",
|
|
@@ -139,28 +150,19 @@ runner.use(_ocap_tx_pipeline.pipes.VerifyDelegation({
|
|
|
139
150
|
const context = ctx;
|
|
140
151
|
const tokens = context.tokens || [];
|
|
141
152
|
const assets = context.assets || [];
|
|
153
|
+
const toAddresses = context.receiverState ? (0, _ocap_util_lib_get_related_addr.getRelatedAddresses)(context.receiverState) : [context.itx.to];
|
|
142
154
|
return [...tokens.map((x) => ({
|
|
143
155
|
type: "token",
|
|
144
156
|
address: x.address,
|
|
145
157
|
value: x.value,
|
|
146
|
-
to:
|
|
158
|
+
to: toAddresses
|
|
147
159
|
})), ...assets.map((x) => ({
|
|
148
160
|
type: "asset",
|
|
149
161
|
address: x,
|
|
150
|
-
to:
|
|
162
|
+
to: toAddresses
|
|
151
163
|
}))];
|
|
152
164
|
}
|
|
153
165
|
}));
|
|
154
|
-
runner.use(_ocap_tx_pipeline.pipes.ExtractReceiver({
|
|
155
|
-
from: "itx.to",
|
|
156
|
-
to: "receiver"
|
|
157
|
-
}));
|
|
158
|
-
runner.use(_ocap_tx_pipeline.pipes.ExtractState({
|
|
159
|
-
from: "receiver",
|
|
160
|
-
to: "receiverState",
|
|
161
|
-
status: "OK",
|
|
162
|
-
table: "account"
|
|
163
|
-
}));
|
|
164
166
|
runner.use(_ocap_tx_pipeline.pipes.AntiLandAttack({
|
|
165
167
|
senderState: "senderState",
|
|
166
168
|
receiverState: "receiverState"
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.29.
|
|
6
|
+
"version": "1.29.4",
|
|
7
7
|
"description": "Predefined tx pipeline sets to execute certain type of transactions",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -45,22 +45,22 @@
|
|
|
45
45
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@arcblock/did": "1.29.
|
|
49
|
-
"@arcblock/did-util": "1.29.
|
|
50
|
-
"@arcblock/jwt": "1.29.
|
|
51
|
-
"@arcblock/validator": "1.29.
|
|
52
|
-
"@arcblock/vc": "1.29.
|
|
48
|
+
"@arcblock/did": "1.29.4",
|
|
49
|
+
"@arcblock/did-util": "1.29.4",
|
|
50
|
+
"@arcblock/jwt": "1.29.4",
|
|
51
|
+
"@arcblock/validator": "1.29.4",
|
|
52
|
+
"@arcblock/vc": "1.29.4",
|
|
53
53
|
"@blocklet/xss": "^0.3.7",
|
|
54
|
-
"@ocap/asset": "1.29.
|
|
55
|
-
"@ocap/client": "1.29.
|
|
56
|
-
"@ocap/mcrypto": "1.29.
|
|
57
|
-
"@ocap/merkle-tree": "1.29.
|
|
58
|
-
"@ocap/message": "1.29.
|
|
59
|
-
"@ocap/state": "1.29.
|
|
60
|
-
"@ocap/tx-pipeline": "1.29.
|
|
61
|
-
"@ocap/types": "1.29.
|
|
62
|
-
"@ocap/util": "1.29.
|
|
63
|
-
"@ocap/wallet": "1.29.
|
|
54
|
+
"@ocap/asset": "1.29.4",
|
|
55
|
+
"@ocap/client": "1.29.4",
|
|
56
|
+
"@ocap/mcrypto": "1.29.4",
|
|
57
|
+
"@ocap/merkle-tree": "1.29.4",
|
|
58
|
+
"@ocap/message": "1.29.4",
|
|
59
|
+
"@ocap/state": "1.29.4",
|
|
60
|
+
"@ocap/tx-pipeline": "1.29.4",
|
|
61
|
+
"@ocap/types": "1.29.4",
|
|
62
|
+
"@ocap/util": "1.29.4",
|
|
63
|
+
"@ocap/wallet": "1.29.4",
|
|
64
64
|
"debug": "^4.4.3",
|
|
65
65
|
"deep-diff": "^1.0.2",
|
|
66
66
|
"lodash": "^4.17.23",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"elliptic": "6.5.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@ocap/e2e-test": "1.29.
|
|
75
|
-
"@ocap/statedb-memory": "1.29.
|
|
74
|
+
"@ocap/e2e-test": "1.29.4",
|
|
75
|
+
"@ocap/statedb-memory": "1.29.4",
|
|
76
76
|
"@types/debug": "^4.1.12",
|
|
77
77
|
"@types/lodash": "^4.17.16",
|
|
78
78
|
"start-server-and-test": "^1.14.0"
|