antelopeql 2.0.0-rc.6 → 2.0.0-rc.9
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.
- package/blockchain/get_required_keys.mjs +11 -2
- package/eosio_types/public_key_type.mjs +19 -5
- package/graphql_input_types/configuration.mjs +0 -6
- package/graphql_object_types/packed_transaction.mjs +73 -20
- package/mutation_resolver.mjs +1 -2
- package/package.json +4 -1
- package/send_transaction.mjs +5 -1
- package/serialize_abi.mjs +273 -0
- package/serialize_transaction.mjs +1 -20
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
GraphQLInputObjectType,
|
|
4
|
+
GraphQLList,
|
|
5
|
+
GraphQLString
|
|
6
|
+
} from "graphql";
|
|
2
7
|
|
|
3
8
|
import bytes_type from "../eosio_types/bytes_type.mjs";
|
|
4
9
|
import name_type from "../eosio_types/name_type.mjs";
|
|
@@ -66,7 +71,11 @@ const get_required_keys = {
|
|
|
66
71
|
})
|
|
67
72
|
});
|
|
68
73
|
|
|
69
|
-
const { required_keys } = await data.json();
|
|
74
|
+
const { required_keys, ...error } = await data.json();
|
|
75
|
+
if (error.error)
|
|
76
|
+
throw new GraphQLError(error.message, {
|
|
77
|
+
extensions: error.error
|
|
78
|
+
});
|
|
70
79
|
|
|
71
80
|
return required_keys;
|
|
72
81
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import base58_to_binary from "base58-js/base58_to_binary.mjs";
|
|
2
|
+
import binary_to_base58 from "base58-js/binary_to_base58.mjs";
|
|
1
3
|
import { GraphQLScalarType } from "graphql";
|
|
4
|
+
import ripemd160 from "ripemd160-js/ripemd160.mjs";
|
|
2
5
|
|
|
3
6
|
const public_key_type = new GraphQLScalarType({
|
|
4
|
-
description: `\`Public key type\`
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
Public keys should begin with PUB_K1 (or EOS for legacy keys) and include base58 characters only.
|
|
8
|
-
`,
|
|
9
7
|
name: "public_key",
|
|
10
8
|
async parseValue(public_key) {
|
|
11
9
|
if (public_key == "") return "";
|
|
@@ -21,6 +19,22 @@ const public_key_type = new GraphQLScalarType({
|
|
|
21
19
|
);
|
|
22
20
|
|
|
23
21
|
return public_key;
|
|
22
|
+
},
|
|
23
|
+
async serialize(key) {
|
|
24
|
+
if (key.startsWith("EOS")) {
|
|
25
|
+
const public_key = base58_to_binary(key.replace(/^[A-Z]+/gmu, "")).slice(
|
|
26
|
+
0,
|
|
27
|
+
-4
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const hash = await ripemd160(Uint8Array.from([...public_key, 75, 49]));
|
|
31
|
+
const checksum = hash.slice(0, 4);
|
|
32
|
+
return (
|
|
33
|
+
"PUB_K1_" +
|
|
34
|
+
binary_to_base58(new Uint8Array([...public_key, ...checksum]))
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return key;
|
|
24
38
|
}
|
|
25
39
|
});
|
|
26
40
|
|
|
@@ -17,7 +17,6 @@ const configuration_default_value = {
|
|
|
17
17
|
* @param {Number} expireSeconds Seconds past before transaction is no longer valid (TaPoS protection)
|
|
18
18
|
* @param {Number} max_net_usage_words Maximum NET bandwidth usage a transaction can consume (0 there is no limit).
|
|
19
19
|
* @param {Number} max_cpu_usage_ms Maximum NET bandwidth usage a transaction can consume (0 there is no limit).
|
|
20
|
-
* @param {Number} delay_sec Number of seconds that the transaciton will be delayed by.
|
|
21
20
|
*/
|
|
22
21
|
const configuration_type = new GraphQLInputObjectType({
|
|
23
22
|
name: "configuration_type",
|
|
@@ -43,11 +42,6 @@ const configuration_type = new GraphQLInputObjectType({
|
|
|
43
42
|
description: `Maximum CPU bandwidth usage a transaction can consume, \nwhen set to 0 there is no limit`,
|
|
44
43
|
type: GraphQLInt,
|
|
45
44
|
defaultValue: configuration_default_value.max_cpu_usage_ms
|
|
46
|
-
},
|
|
47
|
-
delay_sec: {
|
|
48
|
-
type: GraphQLInt,
|
|
49
|
-
description: "Number of seconds that the transaciton will be delayed by",
|
|
50
|
-
defaultValue: configuration_default_value.delay_sec
|
|
51
45
|
}
|
|
52
46
|
})
|
|
53
47
|
});
|
|
@@ -1,7 +1,78 @@
|
|
|
1
|
-
import { GraphQLList, GraphQLObjectType } from "graphql";
|
|
1
|
+
import { GraphQLError, GraphQLList, GraphQLObjectType } from "graphql";
|
|
2
|
+
import sha256 from "universal-sha256-js/sha256.mjs";
|
|
2
3
|
|
|
3
4
|
import bytes_type from "../eosio_types/bytes_type.mjs";
|
|
4
5
|
import public_key_type from "../eosio_types/public_key_type.mjs";
|
|
6
|
+
|
|
7
|
+
export const packed_transaction_fields = {
|
|
8
|
+
chain_id: {
|
|
9
|
+
type: bytes_type,
|
|
10
|
+
description: "A unique ID that specifies which chain we are operating on."
|
|
11
|
+
},
|
|
12
|
+
transaction_header: {
|
|
13
|
+
type: bytes_type,
|
|
14
|
+
description: "Serialized transaction header."
|
|
15
|
+
},
|
|
16
|
+
transaction_body: {
|
|
17
|
+
type: bytes_type,
|
|
18
|
+
description: "Serialized transaction body _(bytecode instructions)_."
|
|
19
|
+
},
|
|
20
|
+
required_keys: {
|
|
21
|
+
type: new GraphQLList(public_key_type),
|
|
22
|
+
description: "List of public keys needed to authorize transaction",
|
|
23
|
+
async resolve({ available_keys, transaction }, args, { network }) {
|
|
24
|
+
if (available_keys?.length) {
|
|
25
|
+
const keys = await Promise.all(available_keys);
|
|
26
|
+
|
|
27
|
+
const req = await fetch(
|
|
28
|
+
network.rpc_url + "/v1/chain/get_required_keys",
|
|
29
|
+
{
|
|
30
|
+
method: "post",
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
transaction: {
|
|
33
|
+
...transaction,
|
|
34
|
+
// Transform the transaction.actions into appropriate form for get_required_keys.
|
|
35
|
+
actions: transaction.actions.map(({ hex_data, ...action }) => ({
|
|
36
|
+
...action,
|
|
37
|
+
data: hex_data
|
|
38
|
+
}))
|
|
39
|
+
},
|
|
40
|
+
available_keys: keys
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
).then((res) => res.json());
|
|
44
|
+
|
|
45
|
+
if (req.error)
|
|
46
|
+
throw new GraphQLError(req.message, { extensions: req.error });
|
|
47
|
+
return req.required_keys;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
hash: {
|
|
52
|
+
type: bytes_type,
|
|
53
|
+
description: "Transaction hash to sign to authorize transaction",
|
|
54
|
+
async resolve({ chain_id, transaction_header, transaction_body }) {
|
|
55
|
+
const transaction_bytes =
|
|
56
|
+
chain_id +
|
|
57
|
+
transaction_header +
|
|
58
|
+
transaction_body +
|
|
59
|
+
"0000000000000000000000000000000000000000000000000000000000000000";
|
|
60
|
+
|
|
61
|
+
const hash_to_sign = await sha256(
|
|
62
|
+
Uint8Array.from(
|
|
63
|
+
transaction_bytes
|
|
64
|
+
.match(/[a-fA-F0-9]{2}/gmu)
|
|
65
|
+
.map((i) => Number(`0x${i}`))
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return [...hash_to_sign]
|
|
70
|
+
.map((x) => Number(x).toString(16).padStart(2, "0"))
|
|
71
|
+
.join("");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
5
76
|
/**
|
|
6
77
|
* The packed transaction type.
|
|
7
78
|
* @kind typedef
|
|
@@ -11,29 +82,11 @@ import public_key_type from "../eosio_types/public_key_type.mjs";
|
|
|
11
82
|
* @prop {String} transaction_header Hex string representing the serialized transaction header.
|
|
12
83
|
* @prop {String} transaction_body Hex string representing the serialized transaction body.
|
|
13
84
|
* @prop {String} transaction_body Hex string representing the serialized transaction body.
|
|
14
|
-
|
|
15
85
|
*/
|
|
16
86
|
const packed_transaction_type = new GraphQLObjectType({
|
|
17
87
|
name: "packed_transaction",
|
|
18
88
|
description: "Packed transaction, chain ID and transaction header",
|
|
19
|
-
fields:
|
|
20
|
-
chain_id: {
|
|
21
|
-
type: bytes_type,
|
|
22
|
-
description: "A unique ID that specifies which chain we are operating on."
|
|
23
|
-
},
|
|
24
|
-
transaction_header: {
|
|
25
|
-
type: bytes_type,
|
|
26
|
-
description: "Serialized transaction header."
|
|
27
|
-
},
|
|
28
|
-
transaction_body: {
|
|
29
|
-
type: bytes_type,
|
|
30
|
-
description: "Serialized transaction body _(bytecode instructions)_."
|
|
31
|
-
},
|
|
32
|
-
required_keys: {
|
|
33
|
-
type: new GraphQLList(public_key_type),
|
|
34
|
-
description: "List of public keys needed to authorize transaction"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
89
|
+
fields: packed_transaction_fields
|
|
37
90
|
});
|
|
38
91
|
|
|
39
92
|
export default packed_transaction_type;
|
package/mutation_resolver.mjs
CHANGED
|
@@ -48,8 +48,7 @@ async function get_transaction_body(actions, ast_list) {
|
|
|
48
48
|
let _actions = [];
|
|
49
49
|
let _context_free_actions = [];
|
|
50
50
|
|
|
51
|
-
let transaction_extensions =
|
|
52
|
-
"000000000000000000000000000000000000000000000000000000000000000000";
|
|
51
|
+
let transaction_extensions = "00";
|
|
53
52
|
|
|
54
53
|
for (const action of actions_list_to_serialize) {
|
|
55
54
|
const {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antelopeql",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.9",
|
|
4
4
|
"description": "A GraphQL implementation for interacting with Antelope based blockchains.",
|
|
5
5
|
"repository": "github:pur3miish/antelopeql",
|
|
6
6
|
"bugs": "https://github.com/pur3miish/antelopeql/issues",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"send_serialized_transaction.mjs",
|
|
39
39
|
"send_transaction_rpc.mjs",
|
|
40
40
|
"send_transaction.mjs",
|
|
41
|
+
"serialize_abi.mjs",
|
|
41
42
|
"serialize_transaction.mjs",
|
|
42
43
|
"types.mjs"
|
|
43
44
|
],
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
"./send_serialized_transaction.mjs": "./send_serialized_transaction.mjs",
|
|
59
60
|
"./send_transaction_rpc.mjs": "./send_transaction_rpc.mjs",
|
|
60
61
|
"./send_transaction.mjs": "./send_transaction.mjs",
|
|
62
|
+
"./serialize_abi.mjs": "./serialize_abi.mjs",
|
|
61
63
|
"./serialize_transaction.mjs": "./serialize_transaction.mjs",
|
|
62
64
|
"./types.mjs": "./types.mjs"
|
|
63
65
|
},
|
|
@@ -77,6 +79,7 @@
|
|
|
77
79
|
],
|
|
78
80
|
"devDependencies": {
|
|
79
81
|
"@types/node": "^18.13.0",
|
|
82
|
+
"antelope-ecc": "^2.0.0-rc.7",
|
|
80
83
|
"coverage-node": "^8.0.0",
|
|
81
84
|
"eslint": "^8.34.0",
|
|
82
85
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
package/send_transaction.mjs
CHANGED
|
@@ -22,7 +22,11 @@ const send_transaction = (actions, ast_list) => ({
|
|
|
22
22
|
const { chain_id, transaction_header, transaction_body, transaction } =
|
|
23
23
|
await mutation_resolver(args, network, ast_list);
|
|
24
24
|
|
|
25
|
-
const transaction_bytes =
|
|
25
|
+
const transaction_bytes =
|
|
26
|
+
chain_id +
|
|
27
|
+
transaction_header +
|
|
28
|
+
transaction_body +
|
|
29
|
+
"0000000000000000000000000000000000000000000000000000000000000000";
|
|
26
30
|
|
|
27
31
|
const hash_to_sign = await sha256(
|
|
28
32
|
Uint8Array.from(
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import serialize from "eosio-wasm-js/serialize.mjs";
|
|
2
|
+
|
|
3
|
+
import { eosio_abi_to_graphql_ast } from "./eosio_abi_to_graphql_ast.mjs";
|
|
4
|
+
|
|
5
|
+
const ABI = {
|
|
6
|
+
version: "eosio::abi/1.1",
|
|
7
|
+
structs: [
|
|
8
|
+
{
|
|
9
|
+
name: "extensions_entry",
|
|
10
|
+
base: "",
|
|
11
|
+
fields: [
|
|
12
|
+
{
|
|
13
|
+
name: "tag",
|
|
14
|
+
type: "uint16"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "value",
|
|
18
|
+
type: "bytes"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "type_def",
|
|
24
|
+
base: "",
|
|
25
|
+
fields: [
|
|
26
|
+
{
|
|
27
|
+
name: "new_type_name",
|
|
28
|
+
type: "string"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "type",
|
|
32
|
+
type: "string"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "field_def",
|
|
38
|
+
base: "",
|
|
39
|
+
fields: [
|
|
40
|
+
{
|
|
41
|
+
name: "name",
|
|
42
|
+
type: "string"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "type",
|
|
46
|
+
type: "string"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "struct_def",
|
|
52
|
+
base: "",
|
|
53
|
+
fields: [
|
|
54
|
+
{
|
|
55
|
+
name: "name",
|
|
56
|
+
type: "string"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "base",
|
|
60
|
+
type: "string"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "fields",
|
|
64
|
+
type: "field_def[]"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "action_def",
|
|
70
|
+
base: "",
|
|
71
|
+
fields: [
|
|
72
|
+
{
|
|
73
|
+
name: "name",
|
|
74
|
+
type: "name"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "type",
|
|
78
|
+
type: "string"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "ricardian_contract",
|
|
82
|
+
type: "string"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "table_def",
|
|
88
|
+
base: "",
|
|
89
|
+
fields: [
|
|
90
|
+
{
|
|
91
|
+
name: "name",
|
|
92
|
+
type: "name"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "index_type",
|
|
96
|
+
type: "string"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "key_names",
|
|
100
|
+
type: "string[]"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "key_types",
|
|
104
|
+
type: "string[]"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "type",
|
|
108
|
+
type: "string"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "clause_pair",
|
|
114
|
+
base: "",
|
|
115
|
+
fields: [
|
|
116
|
+
{
|
|
117
|
+
name: "id",
|
|
118
|
+
type: "string"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "body",
|
|
122
|
+
type: "string"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "error_message",
|
|
128
|
+
base: "",
|
|
129
|
+
fields: [
|
|
130
|
+
{
|
|
131
|
+
name: "error_code",
|
|
132
|
+
type: "uint64"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "error_msg",
|
|
136
|
+
type: "string"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "variant_def",
|
|
142
|
+
base: "",
|
|
143
|
+
fields: [
|
|
144
|
+
{
|
|
145
|
+
name: "name",
|
|
146
|
+
type: "string"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "types",
|
|
150
|
+
type: "string[]"
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "abi_def",
|
|
156
|
+
base: "",
|
|
157
|
+
fields: [
|
|
158
|
+
{
|
|
159
|
+
name: "version",
|
|
160
|
+
type: "string"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "types",
|
|
164
|
+
type: "type_def[]"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "structs",
|
|
168
|
+
type: "struct_def[]"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "actions",
|
|
172
|
+
type: "action_def[]"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "tables",
|
|
176
|
+
type: "table_def[]"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "ricardian_clauses",
|
|
180
|
+
type: "clause_pair[]"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "error_messages",
|
|
184
|
+
type: "error_message[]"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "abi_extensions",
|
|
188
|
+
type: "extensions_entry[]"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "variants",
|
|
192
|
+
type: "variant_def[]$"
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const AST = eosio_abi_to_graphql_ast(ABI);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Given a Smart contract convert the ABI to serialized byte code representation.
|
|
203
|
+
* @param {Object} abi JS Object of the Antelope ABI for a given smart contract.
|
|
204
|
+
* @returns {String} serialized Byte code representation of the ABI.
|
|
205
|
+
*/
|
|
206
|
+
export default async function serialize_abi(abi) {
|
|
207
|
+
let JSON_ABI = abi;
|
|
208
|
+
|
|
209
|
+
ABI.structs[9].fields.forEach(({ name }) => {
|
|
210
|
+
if (JSON_ABI[name] == undefined) {
|
|
211
|
+
JSON_ABI[name] = [];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const build_serialize_list = async (data, instructions) => {
|
|
216
|
+
const serialize_list = [];
|
|
217
|
+
|
|
218
|
+
for (const instruction of instructions) {
|
|
219
|
+
const { $info, name, type } = instruction;
|
|
220
|
+
const datum = data[name];
|
|
221
|
+
|
|
222
|
+
const next_instruction = AST[type];
|
|
223
|
+
|
|
224
|
+
if ($info.variant) {
|
|
225
|
+
if (Object.keys(data).length > 1)
|
|
226
|
+
throw new Error(`Must only include one type for variant.`);
|
|
227
|
+
if (!datum) continue;
|
|
228
|
+
else
|
|
229
|
+
serialize_list.push({
|
|
230
|
+
type: "varuint32",
|
|
231
|
+
value: instructions.findIndex((i) => i.type == type)
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if ($info.binary_ex) $info.optional = false; // Binary extentions are optional (GraphQL types) but should not serialize an optional type.
|
|
236
|
+
|
|
237
|
+
if ($info.optional)
|
|
238
|
+
serialize_list.push({ type: "bool", value: datum != undefined }); // Add an optional item to serialize list.
|
|
239
|
+
|
|
240
|
+
if ($info.list)
|
|
241
|
+
if (datum !== undefined)
|
|
242
|
+
serialize_list.push({ type: "varuint32", value: datum.length }); // Add an length of list to serialize list.
|
|
243
|
+
|
|
244
|
+
// Indicates that we need to recursion loop through each data item.
|
|
245
|
+
if (next_instruction)
|
|
246
|
+
if ($info.list) {
|
|
247
|
+
if (datum != undefined && !$info.binary_ex)
|
|
248
|
+
for await (const d of datum)
|
|
249
|
+
serialize_list.push(
|
|
250
|
+
...(await build_serialize_list(await d, next_instruction))
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
// None list recursion
|
|
254
|
+
else
|
|
255
|
+
serialize_list.push(
|
|
256
|
+
...(await build_serialize_list(datum, next_instruction))
|
|
257
|
+
);
|
|
258
|
+
// Indicates that the list of data can be serilaized and so is pushed into serialize_list.
|
|
259
|
+
else if ($info.list && datum !== undefined)
|
|
260
|
+
for await (const d of datum) serialize_list.push({ type, value: d });
|
|
261
|
+
else if (datum !== undefined) serialize_list.push({ type, value: datum }); // Native eoio types than can be serialized.
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return serialize_list;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const ser_list = await build_serialize_list(JSON_ABI, AST.abi_def);
|
|
268
|
+
|
|
269
|
+
let hex_string = "";
|
|
270
|
+
ser_list.forEach(({ type, value }) => (hex_string += serialize[type](value)));
|
|
271
|
+
|
|
272
|
+
return hex_string;
|
|
273
|
+
}
|
|
@@ -26,26 +26,7 @@ const serialize_transaction = (actions, ast_list) => ({
|
|
|
26
26
|
ast_list
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
if (available_keys?.length) {
|
|
31
|
-
try {
|
|
32
|
-
const { required_keys: rk } = await fetch(
|
|
33
|
-
network.rpc_url + "/v1/chain/get_required_keys",
|
|
34
|
-
{
|
|
35
|
-
method: "post",
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
transaction,
|
|
38
|
-
available_keys: await Promise.all(available_keys)
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
).then((res) => res.json);
|
|
42
|
-
required_keys = rk;
|
|
43
|
-
} catch (err) {
|
|
44
|
-
// gracefully catch the error
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return { ...serialized_txn, required_keys };
|
|
29
|
+
return { ...serialized_txn, available_keys, transaction };
|
|
49
30
|
}
|
|
50
31
|
});
|
|
51
32
|
|