koilib 2.8.0 → 3.0.0
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/README.md +61 -7
- package/dist/koinos.js +8404 -200
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +46 -7
- package/lib/Contract.js +89 -21
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +16 -3
- package/lib/Provider.js +36 -6
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +2 -1
- package/lib/Serializer.js +50 -37
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +42 -42
- package/lib/Signer.js +294 -112
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +46 -7
- package/lib/browser/Contract.js +89 -21
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +16 -3
- package/lib/browser/Provider.js +36 -6
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +2 -1
- package/lib/browser/Serializer.js +50 -37
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +42 -42
- package/lib/browser/Signer.js +294 -112
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/indexUtils.d.ts +2 -0
- package/lib/browser/indexUtils.js +15 -0
- package/lib/browser/indexUtils.js.map +1 -0
- package/lib/browser/interface.d.ts +221 -45
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/krc20-proto.json +47 -4
- package/lib/browser/protoModules/protocol-proto.d.ts +2 -0
- package/lib/browser/protoModules/protocol-proto.js +6336 -0
- package/lib/browser/protoModules/protocol-proto.js.map +1 -0
- package/lib/browser/utils.d.ts +18 -254
- package/lib/browser/utils.js +140 -12
- package/lib/browser/utils.js.map +1 -1
- package/lib/browser/utilsNode.d.ts +1021 -0
- package/lib/browser/utilsNode.js +346 -0
- package/lib/browser/utilsNode.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/indexUtils.d.ts +2 -0
- package/lib/indexUtils.js +15 -0
- package/lib/indexUtils.js.map +1 -0
- package/lib/interface.d.ts +221 -45
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/krc20-proto.json +47 -4
- package/lib/protoModules/protocol-proto.d.ts +2 -0
- package/lib/protoModules/protocol-proto.js +6336 -0
- package/lib/protoModules/protocol-proto.js.map +1 -0
- package/lib/utils.d.ts +18 -254
- package/lib/utils.js +140 -12
- package/lib/utils.js.map +1 -1
- package/lib/utilsNode.d.ts +1021 -0
- package/lib/utilsNode.js +346 -0
- package/lib/utilsNode.js.map +1 -0
- package/package.json +1 -1
- package/lib/browser/jsonDescriptors/protocol-proto.json +0 -246
- package/lib/jsonDescriptors/protocol-proto.json +0 -246
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Signer, SignerInterface } from "./Signer";
|
|
2
2
|
import { Provider } from "./Provider";
|
|
3
3
|
import { Serializer } from "./Serializer";
|
|
4
|
-
import { CallContractOperationNested, UploadContractOperationNested, TransactionJsonWait, Abi, TransactionOptions, DecodedOperationJson } from "./interface";
|
|
4
|
+
import { CallContractOperationNested, UploadContractOperationNested, TransactionJsonWait, Abi, TransactionOptions, DecodedOperationJson, DeployOptions } from "./interface";
|
|
5
5
|
/**
|
|
6
6
|
* The contract class contains the contract ID and contract entries
|
|
7
7
|
* definition needed to encode/decode operations during the
|
|
@@ -69,6 +69,24 @@ export declare class Contract {
|
|
|
69
69
|
* const owner = "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb";
|
|
70
70
|
* await koinContract.functions.balanceOf({ owner });
|
|
71
71
|
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example using options
|
|
74
|
+
* ```ts
|
|
75
|
+
* await koinContract.functions.transfer({
|
|
76
|
+
* from: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
77
|
+
* to: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
78
|
+
* value: "1",
|
|
79
|
+
* },{
|
|
80
|
+
* chainId: "EiB-hw5ABo-EXy6fGDd1Iq3gbAenxQ4Qe60pRbEVMVrR9A==",
|
|
81
|
+
* rcLimit: "100000000",
|
|
82
|
+
* nonce: "OAI=",
|
|
83
|
+
* payer: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
84
|
+
* payee: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
85
|
+
* signTransaction: true,
|
|
86
|
+
* sendTransaction: true,
|
|
87
|
+
* sendAbis: true,
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
72
90
|
*/
|
|
73
91
|
functions: {
|
|
74
92
|
[x: string]: <T = Record<string, unknown>>(args?: unknown, opts?: TransactionOptions) => Promise<{
|
|
@@ -118,10 +136,6 @@ export declare class Contract {
|
|
|
118
136
|
*/
|
|
119
137
|
serializer?: Serializer;
|
|
120
138
|
});
|
|
121
|
-
/**
|
|
122
|
-
* Compute contract Id
|
|
123
|
-
*/
|
|
124
|
-
static computeContractId(address: string): Uint8Array;
|
|
125
139
|
/**
|
|
126
140
|
* Get contract Id
|
|
127
141
|
*/
|
|
@@ -141,10 +155,35 @@ export declare class Contract {
|
|
|
141
155
|
* const blockNumber = await transaction.wait();
|
|
142
156
|
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
143
157
|
* ```
|
|
158
|
+
*
|
|
159
|
+
* @example using options
|
|
160
|
+
* ```ts
|
|
161
|
+
* const { transaction } = await contract.deploy({
|
|
162
|
+
* // contract options
|
|
163
|
+
* abi: "CssCChRrb2lub3Mvb3B0aW9ucy5wc...",
|
|
164
|
+
* authorizesCallContract: true,
|
|
165
|
+
* authorizesTransactionApplication: true,
|
|
166
|
+
* authorizesUploadContract: true,
|
|
167
|
+
*
|
|
168
|
+
* // transaction options
|
|
169
|
+
* chainId: "EiB-hw5ABo-EXy6fGDd1Iq3gbAenxQ4Qe60pRbEVMVrR9A==",
|
|
170
|
+
* rcLimit: "100000000",
|
|
171
|
+
* nonce: "OAI=",
|
|
172
|
+
* payer: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
173
|
+
* payee: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
174
|
+
*
|
|
175
|
+
* // sign and broadcast
|
|
176
|
+
* signTransaction: true,
|
|
177
|
+
* sendTransaction: true,
|
|
178
|
+
* });
|
|
179
|
+
* // wait to be mined
|
|
180
|
+
* const blockNumber = await transaction.wait();
|
|
181
|
+
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
182
|
+
* ```
|
|
144
183
|
*/
|
|
145
|
-
deploy(options?:
|
|
184
|
+
deploy(options?: DeployOptions): Promise<{
|
|
146
185
|
operation: UploadContractOperationNested;
|
|
147
|
-
transaction
|
|
186
|
+
transaction: TransactionJsonWait;
|
|
148
187
|
}>;
|
|
149
188
|
/**
|
|
150
189
|
* Encondes a contract operation using Koinos serialization
|
package/lib/browser/Contract.js
CHANGED
|
@@ -71,7 +71,7 @@ class Contract {
|
|
|
71
71
|
this.serializer = new Serializer_1.Serializer(c.abi.types);
|
|
72
72
|
}
|
|
73
73
|
this.options = {
|
|
74
|
-
|
|
74
|
+
signTransaction: true,
|
|
75
75
|
sendTransaction: true,
|
|
76
76
|
sendAbis: true,
|
|
77
77
|
...c.options,
|
|
@@ -110,7 +110,7 @@ class Contract {
|
|
|
110
110
|
const { result: resultEncoded } = await this.provider.readContract({
|
|
111
111
|
contract_id: (0, utils_1.encodeBase58)(operation.call_contract.contract_id),
|
|
112
112
|
entry_point: operation.call_contract.entry_point,
|
|
113
|
-
args: (0, utils_1.
|
|
113
|
+
args: (0, utils_1.encodeBase64url)(operation.call_contract.args),
|
|
114
114
|
});
|
|
115
115
|
let result = defaultOutput;
|
|
116
116
|
if (resultEncoded) {
|
|
@@ -121,33 +121,47 @@ class Contract {
|
|
|
121
121
|
}
|
|
122
122
|
return { operation, result };
|
|
123
123
|
}
|
|
124
|
-
// return operation if send is false
|
|
125
|
-
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction))
|
|
126
|
-
return { operation };
|
|
127
124
|
// write contract (sign and send)
|
|
128
125
|
if (!this.signer)
|
|
129
126
|
throw new Error("signer not found");
|
|
130
|
-
const tx = await this.signer.
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
const tx = await this.signer.prepareTransaction({
|
|
128
|
+
header: {
|
|
129
|
+
...((opts === null || opts === void 0 ? void 0 : opts.chainId) && { chain_id: opts === null || opts === void 0 ? void 0 : opts.chainId }),
|
|
130
|
+
...((opts === null || opts === void 0 ? void 0 : opts.rcLimit) && { rc_limit: opts === null || opts === void 0 ? void 0 : opts.rcLimit }),
|
|
131
|
+
...((opts === null || opts === void 0 ? void 0 : opts.nonce) && { nonce: opts === null || opts === void 0 ? void 0 : opts.nonce }),
|
|
132
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payer) && { payer: opts === null || opts === void 0 ? void 0 : opts.payer }),
|
|
133
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payee) && { payee: opts === null || opts === void 0 ? void 0 : opts.payee }),
|
|
134
|
+
},
|
|
135
|
+
operations: [
|
|
136
|
+
{
|
|
137
|
+
call_contract: {
|
|
138
|
+
contract_id: (0, utils_1.encodeBase58)(operation.call_contract.contract_id),
|
|
139
|
+
entry_point: operation.call_contract.entry_point,
|
|
140
|
+
args: (0, utils_1.encodeBase64url)(operation.call_contract.args),
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
],
|
|
133
144
|
});
|
|
134
145
|
const abis = {};
|
|
135
146
|
if (opts === null || opts === void 0 ? void 0 : opts.sendAbis) {
|
|
136
147
|
const contractId = (0, utils_1.encodeBase58)(this.id);
|
|
137
148
|
abis[contractId] = this.abi;
|
|
138
149
|
}
|
|
150
|
+
// return result if the transaction will not be broadcasted
|
|
151
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction)) {
|
|
152
|
+
const noWait = () => {
|
|
153
|
+
throw new Error("This transaction was not broadcasted");
|
|
154
|
+
};
|
|
155
|
+
if (opts.signTransaction)
|
|
156
|
+
await this.signer.signTransaction(tx, abis);
|
|
157
|
+
return { operation, transaction: { ...tx, wait: noWait } };
|
|
158
|
+
}
|
|
139
159
|
const transaction = await this.signer.sendTransaction(tx, abis);
|
|
140
160
|
return { operation, transaction };
|
|
141
161
|
};
|
|
142
162
|
});
|
|
143
163
|
}
|
|
144
164
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Compute contract Id
|
|
147
|
-
*/
|
|
148
|
-
static computeContractId(address) {
|
|
149
|
-
return (0, utils_1.decodeBase58)(address);
|
|
150
|
-
}
|
|
151
165
|
/**
|
|
152
166
|
* Get contract Id
|
|
153
167
|
*/
|
|
@@ -171,6 +185,31 @@ class Contract {
|
|
|
171
185
|
* const blockNumber = await transaction.wait();
|
|
172
186
|
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
173
187
|
* ```
|
|
188
|
+
*
|
|
189
|
+
* @example using options
|
|
190
|
+
* ```ts
|
|
191
|
+
* const { transaction } = await contract.deploy({
|
|
192
|
+
* // contract options
|
|
193
|
+
* abi: "CssCChRrb2lub3Mvb3B0aW9ucy5wc...",
|
|
194
|
+
* authorizesCallContract: true,
|
|
195
|
+
* authorizesTransactionApplication: true,
|
|
196
|
+
* authorizesUploadContract: true,
|
|
197
|
+
*
|
|
198
|
+
* // transaction options
|
|
199
|
+
* chainId: "EiB-hw5ABo-EXy6fGDd1Iq3gbAenxQ4Qe60pRbEVMVrR9A==",
|
|
200
|
+
* rcLimit: "100000000",
|
|
201
|
+
* nonce: "OAI=",
|
|
202
|
+
* payer: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
203
|
+
* payee: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
204
|
+
*
|
|
205
|
+
* // sign and broadcast
|
|
206
|
+
* signTransaction: true,
|
|
207
|
+
* sendTransaction: true,
|
|
208
|
+
* });
|
|
209
|
+
* // wait to be mined
|
|
210
|
+
* const blockNumber = await transaction.wait();
|
|
211
|
+
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
212
|
+
* ```
|
|
174
213
|
*/
|
|
175
214
|
async deploy(options) {
|
|
176
215
|
if (!this.signer)
|
|
@@ -183,17 +222,46 @@ class Contract {
|
|
|
183
222
|
};
|
|
184
223
|
const operation = {
|
|
185
224
|
upload_contract: {
|
|
186
|
-
contract_id:
|
|
225
|
+
contract_id: (0, utils_1.decodeBase58)(this.signer.getAddress()),
|
|
187
226
|
bytecode: this.bytecode,
|
|
188
227
|
},
|
|
189
228
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
229
|
+
const tx = await this.signer.prepareTransaction({
|
|
230
|
+
header: {
|
|
231
|
+
...((opts === null || opts === void 0 ? void 0 : opts.chainId) && { chain_id: opts === null || opts === void 0 ? void 0 : opts.chainId }),
|
|
232
|
+
...((opts === null || opts === void 0 ? void 0 : opts.rcLimit) && { rc_limit: opts === null || opts === void 0 ? void 0 : opts.rcLimit }),
|
|
233
|
+
...((opts === null || opts === void 0 ? void 0 : opts.nonce) && { nonce: opts === null || opts === void 0 ? void 0 : opts.nonce }),
|
|
234
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payer) && { payer: opts === null || opts === void 0 ? void 0 : opts.payer }),
|
|
235
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payee) && { payee: opts === null || opts === void 0 ? void 0 : opts.payee }),
|
|
236
|
+
},
|
|
237
|
+
operations: [
|
|
238
|
+
{
|
|
239
|
+
upload_contract: {
|
|
240
|
+
contract_id: (0, utils_1.encodeBase58)(operation.upload_contract.contract_id),
|
|
241
|
+
bytecode: (0, utils_1.encodeBase64url)(this.bytecode),
|
|
242
|
+
...((opts === null || opts === void 0 ? void 0 : opts.abi) && { abi: opts === null || opts === void 0 ? void 0 : opts.abi }),
|
|
243
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract) && {
|
|
244
|
+
authorizes_call_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract,
|
|
245
|
+
}),
|
|
246
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication) && {
|
|
247
|
+
authorizes_transaction_application: opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication,
|
|
248
|
+
}),
|
|
249
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract) && {
|
|
250
|
+
authorizes_upload_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract,
|
|
251
|
+
}),
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
],
|
|
196
255
|
});
|
|
256
|
+
// return result if the transaction will not be broadcasted
|
|
257
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction)) {
|
|
258
|
+
const noWait = () => {
|
|
259
|
+
throw new Error("This transaction was not broadcasted");
|
|
260
|
+
};
|
|
261
|
+
if (opts.signTransaction)
|
|
262
|
+
await this.signer.signTransaction(tx);
|
|
263
|
+
return { operation, transaction: { ...tx, wait: noWait } };
|
|
264
|
+
}
|
|
197
265
|
const transaction = await this.signer.sendTransaction(tx);
|
|
198
266
|
return { operation, transaction };
|
|
199
267
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contract.js","sourceRoot":"","sources":["../../src/Contract.ts"],"names":[],"mappings":";;;AAGA,6CAA0C;
|
|
1
|
+
{"version":3,"file":"Contract.js","sourceRoot":"","sources":["../../src/Contract.ts"],"names":[],"mappings":";;;AAGA,6CAA0C;AAW1C,mCAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAa,QAAQ;IA8EnB,YAAY,CAcX;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,CAAC,EAAE;YAChE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,EAAE,CAAC,aAAa,CAAC,WAAW,KAAK,MAAM,CAAC,UAAU,EAAE;gBACtD,IAAI,CAAC,MAAM,CAAC,KAAK;oBAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBAC3C,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CACrC,EAAE,CAAC,aAAa,CAAC,IAAI,EACrB,MAAM,CAAC,KAAK,CACb;iBACF,CAAC;aACH;SACF;QACD,MAAM,IAAI,KAAK,CAAC,qBAAqB,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACvE,CAAC;CACF;AAhbD,4BAgbC;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -60,16 +60,19 @@ export declare class Provider {
|
|
|
60
60
|
* transactions for a particular account. This call is used
|
|
61
61
|
* when creating new transactions.
|
|
62
62
|
* @param account - account address
|
|
63
|
+
* @param deserialize - If set true it will deserialize the nonce
|
|
64
|
+
* and return it as number (default). If set false it will return
|
|
65
|
+
* the nonce encoded as received from the RPC.
|
|
63
66
|
* @returns Nonce
|
|
64
67
|
*/
|
|
65
|
-
getNonce(account: string): Promise<number>;
|
|
68
|
+
getNonce(account: string, deserialize?: boolean): Promise<number | string>;
|
|
66
69
|
getAccountRc(account: string): Promise<string>;
|
|
67
70
|
/**
|
|
68
71
|
* Get transactions by id and their corresponding block ids
|
|
69
72
|
*/
|
|
70
73
|
getTransactionsById(transactionIds: string[]): Promise<{
|
|
71
74
|
transactions: {
|
|
72
|
-
transaction: TransactionJson
|
|
75
|
+
transaction: TransactionJson;
|
|
73
76
|
containing_blocks: string[];
|
|
74
77
|
}[];
|
|
75
78
|
}>;
|
|
@@ -89,8 +92,13 @@ export declare class Provider {
|
|
|
89
92
|
height: string;
|
|
90
93
|
previous: string;
|
|
91
94
|
};
|
|
95
|
+
head_state_merkle_root: string;
|
|
92
96
|
last_irreversible_block: string;
|
|
93
97
|
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Function to get the chain
|
|
100
|
+
*/
|
|
101
|
+
getChainId(): Promise<string>;
|
|
94
102
|
/**
|
|
95
103
|
* Function to get consecutive blocks in descending order
|
|
96
104
|
* @param height - Starting block height
|
|
@@ -146,7 +154,12 @@ export declare class Provider {
|
|
|
146
154
|
* Function to call "chain.submit_transaction" to send a signed
|
|
147
155
|
* transaction to the blockchain.
|
|
148
156
|
*/
|
|
149
|
-
sendTransaction(transaction: TransactionJson): Promise<
|
|
157
|
+
sendTransaction(transaction: TransactionJson): Promise<Record<string, never>>;
|
|
158
|
+
/**
|
|
159
|
+
* Function to call "chain.submit_block" to send a signed
|
|
160
|
+
* block to the blockchain.
|
|
161
|
+
*/
|
|
162
|
+
submitBlock(block: BlockJson): Promise<Record<string, never>>;
|
|
150
163
|
/**
|
|
151
164
|
* Function to call "chain.read_contract" to read a contract.
|
|
152
165
|
* This function is used by [[Contract]] class when read methods
|
package/lib/browser/Provider.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Provider = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
const protocol_proto_js_1 = require("./protoModules/protocol-proto.js");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
4
9
|
async function sleep(ms) {
|
|
5
10
|
return new Promise((r) => setTimeout(r, ms));
|
|
6
11
|
}
|
|
@@ -76,13 +81,24 @@ class Provider {
|
|
|
76
81
|
* transactions for a particular account. This call is used
|
|
77
82
|
* when creating new transactions.
|
|
78
83
|
* @param account - account address
|
|
84
|
+
* @param deserialize - If set true it will deserialize the nonce
|
|
85
|
+
* and return it as number (default). If set false it will return
|
|
86
|
+
* the nonce encoded as received from the RPC.
|
|
79
87
|
* @returns Nonce
|
|
80
88
|
*/
|
|
81
|
-
async getNonce(account) {
|
|
82
|
-
const { nonce } = await this.call("chain.get_account_nonce", { account });
|
|
83
|
-
if (!
|
|
84
|
-
return
|
|
85
|
-
|
|
89
|
+
async getNonce(account, deserialize = true) {
|
|
90
|
+
const { nonce: nonceBase64url } = await this.call("chain.get_account_nonce", { account });
|
|
91
|
+
if (!deserialize) {
|
|
92
|
+
return nonceBase64url;
|
|
93
|
+
}
|
|
94
|
+
const valueBuffer = (0, utils_1.decodeBase64url)(nonceBase64url);
|
|
95
|
+
const message = protocol_proto_js_1.koinos.chain.value_type.decode(valueBuffer);
|
|
96
|
+
const object = protocol_proto_js_1.koinos.chain.value_type.toObject(message, {
|
|
97
|
+
longs: String,
|
|
98
|
+
defaults: true,
|
|
99
|
+
});
|
|
100
|
+
// todo: consider the case where nonce is greater than max safe integer
|
|
101
|
+
return Number(object.uint64_value);
|
|
86
102
|
}
|
|
87
103
|
async getAccountRc(account) {
|
|
88
104
|
const { rc } = await this.call("chain.get_account_rc", {
|
|
@@ -102,7 +118,7 @@ class Provider {
|
|
|
102
118
|
}
|
|
103
119
|
async getBlocksById(blockIds) {
|
|
104
120
|
return this.call("block_store.get_blocks_by_id", {
|
|
105
|
-
|
|
121
|
+
block_ids: blockIds,
|
|
106
122
|
return_block: true,
|
|
107
123
|
return_receipt: false,
|
|
108
124
|
});
|
|
@@ -113,6 +129,13 @@ class Provider {
|
|
|
113
129
|
async getHeadInfo() {
|
|
114
130
|
return this.call("chain.get_head_info", {});
|
|
115
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Function to get the chain
|
|
134
|
+
*/
|
|
135
|
+
async getChainId() {
|
|
136
|
+
const { chain_id: chainId } = await this.call("chain.get_chain_id", {});
|
|
137
|
+
return chainId;
|
|
138
|
+
}
|
|
116
139
|
/**
|
|
117
140
|
* Function to get consecutive blocks in descending order
|
|
118
141
|
* @param height - Starting block height
|
|
@@ -232,6 +255,13 @@ class Provider {
|
|
|
232
255
|
async sendTransaction(transaction) {
|
|
233
256
|
return this.call("chain.submit_transaction", { transaction });
|
|
234
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Function to call "chain.submit_block" to send a signed
|
|
260
|
+
* block to the blockchain.
|
|
261
|
+
*/
|
|
262
|
+
async submitBlock(block) {
|
|
263
|
+
return this.call("chain.submit_block", { block });
|
|
264
|
+
}
|
|
235
265
|
/**
|
|
236
266
|
* Function to call "chain.read_contract" to read a contract.
|
|
237
267
|
* This function is used by [[Contract]] class when read methods
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/Provider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/Provider.ts"],"names":[],"mappings":";;;AAKA,6DAA6D;AAC7D,aAAa;AACb,wEAA0D;AAC1D,mCAA0C;AAE1C,2IAA2I;AAE3I,KAAK,UAAU,KAAK,CAAC,EAAU;IAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAa,QAAQ;IAwCnB;;;;;;;;;;;OAWG;IACH,YAAY,QAA2B;QACrC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;;YACjD,IAAI,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,CA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I,EAAE,MAAM,CAAC,GAAG,MAAM,cAAc,CACzC,WAAW,EACX,CAAC,EACD,YAAY,CAAC,EAAE,CAChB,CAAC;YACF,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAC;YACtB,IAAI,CAAC,UAAU;gBAAE,UAAU,GAAG,MAAM,CAAC;YACrC,WAAW,IAAI,CAAC,CAAC;SAClB;QACD,MAAM,IAAI,KAAK,CACb,+BAA+B,OAAO,4BAA4B,QAAQ,OAAO,WAAW,EAAE,CAC/F,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe,CACnB,WAA4B;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,KAAgB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,SAAoC;QAIrD,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;CACF;AA7ZD,4BA6ZC;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -49,7 +49,7 @@ export declare class Serializer {
|
|
|
49
49
|
*/
|
|
50
50
|
defaultType?: Type;
|
|
51
51
|
/**
|
|
52
|
-
* Preformat bytes for
|
|
52
|
+
* Preformat bytes for base64url, base58 or hex string
|
|
53
53
|
*/
|
|
54
54
|
bytesConversion: boolean;
|
|
55
55
|
constructor(types: INamespace, opts?: {
|
|
@@ -65,6 +65,7 @@ export declare class Serializer {
|
|
|
65
65
|
*/
|
|
66
66
|
bytesConversion?: boolean;
|
|
67
67
|
});
|
|
68
|
+
converter(valueDecoded: Record<string, unknown>, object: Record<string, unknown>, protobufType: Type, fieldName: string): void;
|
|
68
69
|
/**
|
|
69
70
|
* Function to encode a type using the protobuffer definitions
|
|
70
71
|
* It also prepares the bytes for special cases (base58, hex string)
|
|
@@ -4,7 +4,7 @@ exports.Serializer = void 0;
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/require-await */
|
|
5
5
|
const light_1 = require("protobufjs/light");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
const OP_BYTES = "(
|
|
7
|
+
const OP_BYTES = "(btype)";
|
|
8
8
|
/**
|
|
9
9
|
* Makes a copy of a value. The returned value can be modified
|
|
10
10
|
* without altering the original one. Although this is not needed
|
|
@@ -58,7 +58,7 @@ function copyValue(value) {
|
|
|
58
58
|
class Serializer {
|
|
59
59
|
constructor(types, opts) {
|
|
60
60
|
/**
|
|
61
|
-
* Preformat bytes for
|
|
61
|
+
* Preformat bytes for base64url, base58 or hex string
|
|
62
62
|
*/
|
|
63
63
|
this.bytesConversion = true;
|
|
64
64
|
this.types = types;
|
|
@@ -68,6 +68,46 @@ class Serializer {
|
|
|
68
68
|
if (opts && typeof opts.bytesConversion !== "undefined")
|
|
69
69
|
this.bytesConversion = opts.bytesConversion;
|
|
70
70
|
}
|
|
71
|
+
converter(valueDecoded, object, protobufType, fieldName) {
|
|
72
|
+
const { options, name, type } = protobufType.fields[fieldName];
|
|
73
|
+
if (!valueDecoded[name])
|
|
74
|
+
return;
|
|
75
|
+
// if operation
|
|
76
|
+
if (type.endsWith("_operation")) {
|
|
77
|
+
const protoBuf = this.root.lookupType(type);
|
|
78
|
+
object[name] = {};
|
|
79
|
+
Object.keys(protoBuf.fields).forEach((fdName) => this.converter(valueDecoded[name], object[name], protoBuf, fdName));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// No byte conversion
|
|
83
|
+
if (type !== "bytes") {
|
|
84
|
+
object[name] = copyValue(valueDecoded[name]);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// Default byte conversion
|
|
88
|
+
if (!options || !options[OP_BYTES]) {
|
|
89
|
+
object[name] = (0, utils_1.decodeBase64url)(valueDecoded[name]);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Specific byte conversion
|
|
93
|
+
switch (options[OP_BYTES]) {
|
|
94
|
+
case "BASE58":
|
|
95
|
+
case "CONTRACT_ID":
|
|
96
|
+
case "ADDRESS":
|
|
97
|
+
object[name] = (0, utils_1.decodeBase58)(valueDecoded[name]);
|
|
98
|
+
break;
|
|
99
|
+
case "BASE64":
|
|
100
|
+
object[name] = (0, utils_1.decodeBase64url)(valueDecoded[name]);
|
|
101
|
+
break;
|
|
102
|
+
case "HEX":
|
|
103
|
+
case "BLOCK_ID":
|
|
104
|
+
case "TRANSACTION_ID":
|
|
105
|
+
object[name] = (0, utils_1.toUint8Array)(valueDecoded[name].replace("0x", ""));
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
throw new Error(`unknown btype ${options[OP_BYTES]}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
71
111
|
/**
|
|
72
112
|
* Function to encode a type using the protobuffer definitions
|
|
73
113
|
* It also prepares the bytes for special cases (base58, hex string)
|
|
@@ -81,37 +121,7 @@ class Serializer {
|
|
|
81
121
|
: opts.bytesConversion;
|
|
82
122
|
if (bytesConversion) {
|
|
83
123
|
// TODO: format from Buffer to base58/base64 for nested fields
|
|
84
|
-
Object.keys(protobufType.fields).forEach((fieldName) =>
|
|
85
|
-
const { options, name, type } = protobufType.fields[fieldName];
|
|
86
|
-
// No byte conversion
|
|
87
|
-
if (type !== "bytes") {
|
|
88
|
-
object[name] = copyValue(valueDecoded[name]);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// Default byte conversion
|
|
92
|
-
if (!options || !options[OP_BYTES]) {
|
|
93
|
-
object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
// Specific byte conversion
|
|
97
|
-
switch (options[OP_BYTES]) {
|
|
98
|
-
case "BASE58":
|
|
99
|
-
case "CONTRACT_ID":
|
|
100
|
-
case "ADDRESS":
|
|
101
|
-
object[name] = (0, utils_1.decodeBase58)(valueDecoded[name]);
|
|
102
|
-
break;
|
|
103
|
-
case "BASE64":
|
|
104
|
-
object[name] = (0, utils_1.decodeBase64)(valueDecoded[name]);
|
|
105
|
-
break;
|
|
106
|
-
case "HEX":
|
|
107
|
-
case "BLOCK_ID":
|
|
108
|
-
case "TRANSACTION_ID":
|
|
109
|
-
object[name] = (0, utils_1.toUint8Array)(valueDecoded[name].replace("0x", ""));
|
|
110
|
-
break;
|
|
111
|
-
default:
|
|
112
|
-
throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
124
|
+
Object.keys(protobufType.fields).forEach((fieldName) => this.converter(valueDecoded, object, protobufType, fieldName));
|
|
115
125
|
}
|
|
116
126
|
else {
|
|
117
127
|
object = valueDecoded;
|
|
@@ -127,11 +137,14 @@ class Serializer {
|
|
|
127
137
|
*/
|
|
128
138
|
async deserialize(valueEncoded, typeName, opts) {
|
|
129
139
|
const valueBuffer = typeof valueEncoded === "string"
|
|
130
|
-
? (0, utils_1.
|
|
140
|
+
? (0, utils_1.decodeBase64url)(valueEncoded)
|
|
131
141
|
: valueEncoded;
|
|
132
142
|
const protobufType = this.defaultType || this.root.lookupType(typeName);
|
|
133
143
|
const message = protobufType.decode(valueBuffer);
|
|
134
|
-
const object = protobufType.toObject(message, {
|
|
144
|
+
const object = protobufType.toObject(message, {
|
|
145
|
+
longs: String,
|
|
146
|
+
defaults: true,
|
|
147
|
+
});
|
|
135
148
|
const bytesConversion = (opts === null || opts === void 0 ? void 0 : opts.bytesConversion) === undefined
|
|
136
149
|
? this.bytesConversion
|
|
137
150
|
: opts.bytesConversion;
|
|
@@ -145,7 +158,7 @@ class Serializer {
|
|
|
145
158
|
return;
|
|
146
159
|
// Default byte conversion
|
|
147
160
|
if (!options || !options[OP_BYTES]) {
|
|
148
|
-
object[name] = (0, utils_1.
|
|
161
|
+
object[name] = (0, utils_1.encodeBase64url)(object[name]);
|
|
149
162
|
return;
|
|
150
163
|
}
|
|
151
164
|
// Specific byte conversion
|
|
@@ -156,7 +169,7 @@ class Serializer {
|
|
|
156
169
|
object[name] = (0, utils_1.encodeBase58)(object[name]);
|
|
157
170
|
break;
|
|
158
171
|
case "BASE64":
|
|
159
|
-
object[name] = (0, utils_1.
|
|
172
|
+
object[name] = (0, utils_1.encodeBase64url)(object[name]);
|
|
160
173
|
break;
|
|
161
174
|
case "HEX":
|
|
162
175
|
case "BLOCK_ID":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAA0D;AAC1D,mCAOiB;AAEjB,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,4CAA0D;AAC1D,mCAOiB;AAEjB,MAAM,QAAQ,GAAG,SAAS,CAAC;AAE3B;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC1D,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAY,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,UAAU;IAsBrB,YACE,KAAiB,EACjB,IAaC;QApBH;;WAEG;QACH,oBAAe,GAAG,IAAI,CAAC;QAmBrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,YAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,IAAI,aAAJ,IAAI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