koilib 2.8.0 → 3.1.1
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 +75 -12
- package/dist/koinos.js +8535 -284
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +66 -18
- package/lib/Contract.js +103 -40
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +22 -7
- package/lib/Provider.js +60 -21
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +3 -1
- package/lib/Serializer.js +103 -83
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +54 -42
- package/lib/Signer.js +305 -114
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +66 -18
- package/lib/browser/Contract.js +103 -40
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +22 -7
- package/lib/browser/Provider.js +60 -21
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +3 -1
- package/lib/browser/Serializer.js +103 -83
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +54 -42
- package/lib/browser/Signer.js +305 -114
- 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 +242 -46
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/{krc20-proto.json → token-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 +19 -255
- package/lib/browser/utils.js +170 -15
- 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 +242 -46
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/{krc20-proto.json → token-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 +19 -255
- package/lib/utils.js +170 -15
- 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
package/lib/Contract.d.ts
CHANGED
|
@@ -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 {
|
|
4
|
+
import { UploadContractOperationNested, TransactionJsonWait, Abi, TransactionOptions, DecodedOperationJson, OperationJson, DeployOptions, TransactionReceipt } 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
|
|
@@ -17,7 +17,7 @@ import { CallContractOperationNested, UploadContractOperationNested, Transaction
|
|
|
17
17
|
* const signer = new Signer({ privateKey, provider });
|
|
18
18
|
* const koinContract = new Contract({
|
|
19
19
|
* id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
20
|
-
* abi: utils.
|
|
20
|
+
* abi: utils.tokenAbi,
|
|
21
21
|
* provider,
|
|
22
22
|
* signer,
|
|
23
23
|
* });
|
|
@@ -40,11 +40,16 @@ import { CallContractOperationNested, UploadContractOperationNested, Transaction
|
|
|
40
40
|
* console.log(result)
|
|
41
41
|
*
|
|
42
42
|
* // Transfer
|
|
43
|
-
* const { transaction } = await koin.transfer({
|
|
43
|
+
* const { transaction, receipt } = await koin.transfer({
|
|
44
44
|
* to: "172AB1FgCsYrRAW5cwQ8KjadgxofvgPFd6",
|
|
45
45
|
* value: "10.0001",
|
|
46
46
|
* });
|
|
47
|
-
* console.log(`Transaction id ${transaction.id} submitted
|
|
47
|
+
* console.log(`Transaction id ${transaction.id} submitted. Receipt:`);
|
|
48
|
+
* console.log(receipt);
|
|
49
|
+
*
|
|
50
|
+
* if (receipt.logs) {
|
|
51
|
+
* console.log(`Transfer failed. Logs: ${receipt.logs.join(",")}`);
|
|
52
|
+
* }
|
|
48
53
|
*
|
|
49
54
|
* // wait to be mined
|
|
50
55
|
* const blockNumber = await transaction.wait();
|
|
@@ -69,12 +74,31 @@ export declare class Contract {
|
|
|
69
74
|
* const owner = "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb";
|
|
70
75
|
* await koinContract.functions.balanceOf({ owner });
|
|
71
76
|
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example using options
|
|
79
|
+
* ```ts
|
|
80
|
+
* await koinContract.functions.transfer({
|
|
81
|
+
* from: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
82
|
+
* to: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
83
|
+
* value: "1",
|
|
84
|
+
* },{
|
|
85
|
+
* chainId: "EiB-hw5ABo-EXy6fGDd1Iq3gbAenxQ4Qe60pRbEVMVrR9A==",
|
|
86
|
+
* rcLimit: "100000000",
|
|
87
|
+
* nonce: "OAI=",
|
|
88
|
+
* payer: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
89
|
+
* payee: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
90
|
+
* signTransaction: true,
|
|
91
|
+
* sendTransaction: true,
|
|
92
|
+
* sendAbis: true,
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
72
95
|
*/
|
|
73
96
|
functions: {
|
|
74
97
|
[x: string]: <T = Record<string, unknown>>(args?: unknown, opts?: TransactionOptions) => Promise<{
|
|
75
|
-
operation:
|
|
98
|
+
operation: OperationJson;
|
|
76
99
|
transaction?: TransactionJsonWait;
|
|
77
100
|
result?: T;
|
|
101
|
+
receipt?: TransactionReceipt;
|
|
78
102
|
}>;
|
|
79
103
|
};
|
|
80
104
|
/**
|
|
@@ -118,10 +142,6 @@ export declare class Contract {
|
|
|
118
142
|
*/
|
|
119
143
|
serializer?: Serializer;
|
|
120
144
|
});
|
|
121
|
-
/**
|
|
122
|
-
* Compute contract Id
|
|
123
|
-
*/
|
|
124
|
-
static computeContractId(address: string): Uint8Array;
|
|
125
145
|
/**
|
|
126
146
|
* Get contract Id
|
|
127
147
|
*/
|
|
@@ -136,15 +156,43 @@ export declare class Contract {
|
|
|
136
156
|
* const signer = new Signer({ privateKey, provider });
|
|
137
157
|
* const bytecode = new Uint8Array([1, 2, 3, 4]);
|
|
138
158
|
* const contract = new Contract({ signer, provider, bytecode });
|
|
139
|
-
* const { transaction } = await contract.deploy();
|
|
159
|
+
* const { transaction, receipt } = await contract.deploy();
|
|
160
|
+
* console.log(receipt);
|
|
161
|
+
* // wait to be mined
|
|
162
|
+
* const blockNumber = await transaction.wait();
|
|
163
|
+
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @example using options
|
|
167
|
+
* ```ts
|
|
168
|
+
* const { transaction, receipt } = await contract.deploy({
|
|
169
|
+
* // contract options
|
|
170
|
+
* abi: "CssCChRrb2lub3Mvb3B0aW9ucy5wc...",
|
|
171
|
+
* authorizesCallContract: true,
|
|
172
|
+
* authorizesTransactionApplication: true,
|
|
173
|
+
* authorizesUploadContract: true,
|
|
174
|
+
*
|
|
175
|
+
* // transaction options
|
|
176
|
+
* chainId: "EiB-hw5ABo-EXy6fGDd1Iq3gbAenxQ4Qe60pRbEVMVrR9A==",
|
|
177
|
+
* rcLimit: "100000000",
|
|
178
|
+
* nonce: "OAI=",
|
|
179
|
+
* payer: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
180
|
+
* payee: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
181
|
+
*
|
|
182
|
+
* // sign and broadcast
|
|
183
|
+
* signTransaction: true,
|
|
184
|
+
* sendTransaction: true,
|
|
185
|
+
* });
|
|
186
|
+
* console.log(receipt);
|
|
140
187
|
* // wait to be mined
|
|
141
188
|
* const blockNumber = await transaction.wait();
|
|
142
189
|
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
143
190
|
* ```
|
|
144
191
|
*/
|
|
145
|
-
deploy(options?:
|
|
192
|
+
deploy(options?: DeployOptions): Promise<{
|
|
146
193
|
operation: UploadContractOperationNested;
|
|
147
|
-
transaction
|
|
194
|
+
transaction: TransactionJsonWait;
|
|
195
|
+
receipt?: TransactionReceipt;
|
|
148
196
|
}>;
|
|
149
197
|
/**
|
|
150
198
|
* Encondes a contract operation using Koinos serialization
|
|
@@ -166,13 +214,13 @@ export declare class Contract {
|
|
|
166
214
|
* // {
|
|
167
215
|
* // call_contract: {
|
|
168
216
|
* // contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
169
|
-
* // entry_point:
|
|
170
|
-
* // args: "
|
|
217
|
+
* // entry_point: 670398154,
|
|
218
|
+
* // args: "ChkAEjl6vrl55V2Oym_rzsnMxIqBoie9PHmMEhkAQgjT1UACatdFY3e5QRkyG7OAzwcCCIylGOgH",
|
|
171
219
|
* // }
|
|
172
220
|
* // }
|
|
173
221
|
* ```
|
|
174
222
|
*/
|
|
175
|
-
encodeOperation(op: DecodedOperationJson): Promise<
|
|
223
|
+
encodeOperation(op: DecodedOperationJson): Promise<OperationJson>;
|
|
176
224
|
/**
|
|
177
225
|
* Decodes a contract operation to be human readable
|
|
178
226
|
* @example
|
|
@@ -180,8 +228,8 @@ export declare class Contract {
|
|
|
180
228
|
* const opDecoded = contract.decodeOperation({
|
|
181
229
|
* call_contract: {
|
|
182
230
|
* contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
183
|
-
* entry_point:
|
|
184
|
-
* args: "
|
|
231
|
+
* entry_point: 0x27f576ca,
|
|
232
|
+
* args: "ChkAEjl6vrl55V2Oym_rzsnMxIqBoie9PHmMEhkAQgjT1UACatdFY3e5QRkyG7OAzwcCCIylGOgH",
|
|
185
233
|
* }
|
|
186
234
|
* });
|
|
187
235
|
* console.log(opDecoded);
|
|
@@ -195,6 +243,6 @@ export declare class Contract {
|
|
|
195
243
|
* // }
|
|
196
244
|
* ```
|
|
197
245
|
*/
|
|
198
|
-
decodeOperation(op:
|
|
246
|
+
decodeOperation(op: OperationJson): Promise<DecodedOperationJson>;
|
|
199
247
|
}
|
|
200
248
|
export default Contract;
|
package/lib/Contract.js
CHANGED
|
@@ -18,7 +18,7 @@ const utils_1 = require("./utils");
|
|
|
18
18
|
* const signer = new Signer({ privateKey, provider });
|
|
19
19
|
* const koinContract = new Contract({
|
|
20
20
|
* id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
21
|
-
* abi: utils.
|
|
21
|
+
* abi: utils.tokenAbi,
|
|
22
22
|
* provider,
|
|
23
23
|
* signer,
|
|
24
24
|
* });
|
|
@@ -41,11 +41,16 @@ const utils_1 = require("./utils");
|
|
|
41
41
|
* console.log(result)
|
|
42
42
|
*
|
|
43
43
|
* // Transfer
|
|
44
|
-
* const { transaction } = await koin.transfer({
|
|
44
|
+
* const { transaction, receipt } = await koin.transfer({
|
|
45
45
|
* to: "172AB1FgCsYrRAW5cwQ8KjadgxofvgPFd6",
|
|
46
46
|
* value: "10.0001",
|
|
47
47
|
* });
|
|
48
|
-
* console.log(`Transaction id ${transaction.id} submitted
|
|
48
|
+
* console.log(`Transaction id ${transaction.id} submitted. Receipt:`);
|
|
49
|
+
* console.log(receipt);
|
|
50
|
+
*
|
|
51
|
+
* if (receipt.logs) {
|
|
52
|
+
* console.log(`Transfer failed. Logs: ${receipt.logs.join(",")}`);
|
|
53
|
+
* }
|
|
49
54
|
*
|
|
50
55
|
* // wait to be mined
|
|
51
56
|
* const blockNumber = await transaction.wait();
|
|
@@ -71,7 +76,7 @@ class Contract {
|
|
|
71
76
|
this.serializer = new Serializer_1.Serializer(c.abi.types);
|
|
72
77
|
}
|
|
73
78
|
this.options = {
|
|
74
|
-
|
|
79
|
+
signTransaction: true,
|
|
75
80
|
sendTransaction: true,
|
|
76
81
|
sendAbis: true,
|
|
77
82
|
...c.options,
|
|
@@ -107,11 +112,7 @@ class Contract {
|
|
|
107
112
|
if (!output)
|
|
108
113
|
throw new Error(`No output defined for ${name}`);
|
|
109
114
|
// read contract
|
|
110
|
-
const { result: resultEncoded } = await this.provider.readContract(
|
|
111
|
-
contract_id: (0, utils_1.encodeBase58)(operation.call_contract.contract_id),
|
|
112
|
-
entry_point: operation.call_contract.entry_point,
|
|
113
|
-
args: (0, utils_1.encodeBase64)(operation.call_contract.args),
|
|
114
|
-
});
|
|
115
|
+
const { result: resultEncoded } = await this.provider.readContract(operation.call_contract);
|
|
115
116
|
let result = defaultOutput;
|
|
116
117
|
if (resultEncoded) {
|
|
117
118
|
result = await this.serializer.deserialize(resultEncoded, output);
|
|
@@ -121,14 +122,17 @@ class Contract {
|
|
|
121
122
|
}
|
|
122
123
|
return { operation, result };
|
|
123
124
|
}
|
|
124
|
-
// return operation if send is false
|
|
125
|
-
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction))
|
|
126
|
-
return { operation };
|
|
127
125
|
// write contract (sign and send)
|
|
128
126
|
if (!this.signer)
|
|
129
127
|
throw new Error("signer not found");
|
|
130
|
-
const tx = await this.signer.
|
|
131
|
-
|
|
128
|
+
const tx = await this.signer.prepareTransaction({
|
|
129
|
+
header: {
|
|
130
|
+
...((opts === null || opts === void 0 ? void 0 : opts.chainId) && { chain_id: opts === null || opts === void 0 ? void 0 : opts.chainId }),
|
|
131
|
+
...((opts === null || opts === void 0 ? void 0 : opts.rcLimit) && { rc_limit: opts === null || opts === void 0 ? void 0 : opts.rcLimit }),
|
|
132
|
+
...((opts === null || opts === void 0 ? void 0 : opts.nonce) && { nonce: opts === null || opts === void 0 ? void 0 : opts.nonce }),
|
|
133
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payer) && { payer: opts === null || opts === void 0 ? void 0 : opts.payer }),
|
|
134
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payee) && { payee: opts === null || opts === void 0 ? void 0 : opts.payee }),
|
|
135
|
+
},
|
|
132
136
|
operations: [operation],
|
|
133
137
|
});
|
|
134
138
|
const abis = {};
|
|
@@ -136,18 +140,21 @@ class Contract {
|
|
|
136
140
|
const contractId = (0, utils_1.encodeBase58)(this.id);
|
|
137
141
|
abis[contractId] = this.abi;
|
|
138
142
|
}
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
// return result if the transaction will not be broadcasted
|
|
144
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction)) {
|
|
145
|
+
const noWait = () => {
|
|
146
|
+
throw new Error("This transaction was not broadcasted");
|
|
147
|
+
};
|
|
148
|
+
if (opts.signTransaction)
|
|
149
|
+
await this.signer.signTransaction(tx, abis);
|
|
150
|
+
return { operation, transaction: { ...tx, wait: noWait } };
|
|
151
|
+
}
|
|
152
|
+
const { transaction, receipt } = await this.signer.sendTransaction(tx, abis);
|
|
153
|
+
return { operation, transaction, receipt };
|
|
141
154
|
};
|
|
142
155
|
});
|
|
143
156
|
}
|
|
144
157
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Compute contract Id
|
|
147
|
-
*/
|
|
148
|
-
static computeContractId(address) {
|
|
149
|
-
return (0, utils_1.decodeBase58)(address);
|
|
150
|
-
}
|
|
151
158
|
/**
|
|
152
159
|
* Get contract Id
|
|
153
160
|
*/
|
|
@@ -166,7 +173,34 @@ class Contract {
|
|
|
166
173
|
* const signer = new Signer({ privateKey, provider });
|
|
167
174
|
* const bytecode = new Uint8Array([1, 2, 3, 4]);
|
|
168
175
|
* const contract = new Contract({ signer, provider, bytecode });
|
|
169
|
-
* const { transaction } = await contract.deploy();
|
|
176
|
+
* const { transaction, receipt } = await contract.deploy();
|
|
177
|
+
* console.log(receipt);
|
|
178
|
+
* // wait to be mined
|
|
179
|
+
* const blockNumber = await transaction.wait();
|
|
180
|
+
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @example using options
|
|
184
|
+
* ```ts
|
|
185
|
+
* const { transaction, receipt } = await contract.deploy({
|
|
186
|
+
* // contract options
|
|
187
|
+
* abi: "CssCChRrb2lub3Mvb3B0aW9ucy5wc...",
|
|
188
|
+
* authorizesCallContract: true,
|
|
189
|
+
* authorizesTransactionApplication: true,
|
|
190
|
+
* authorizesUploadContract: true,
|
|
191
|
+
*
|
|
192
|
+
* // transaction options
|
|
193
|
+
* chainId: "EiB-hw5ABo-EXy6fGDd1Iq3gbAenxQ4Qe60pRbEVMVrR9A==",
|
|
194
|
+
* rcLimit: "100000000",
|
|
195
|
+
* nonce: "OAI=",
|
|
196
|
+
* payer: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
197
|
+
* payee: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
198
|
+
*
|
|
199
|
+
* // sign and broadcast
|
|
200
|
+
* signTransaction: true,
|
|
201
|
+
* sendTransaction: true,
|
|
202
|
+
* });
|
|
203
|
+
* console.log(receipt);
|
|
170
204
|
* // wait to be mined
|
|
171
205
|
* const blockNumber = await transaction.wait();
|
|
172
206
|
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
@@ -183,19 +217,48 @@ class Contract {
|
|
|
183
217
|
};
|
|
184
218
|
const operation = {
|
|
185
219
|
upload_contract: {
|
|
186
|
-
contract_id:
|
|
220
|
+
contract_id: (0, utils_1.decodeBase58)(this.signer.getAddress()),
|
|
187
221
|
bytecode: this.bytecode,
|
|
188
222
|
},
|
|
189
223
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
224
|
+
const tx = await this.signer.prepareTransaction({
|
|
225
|
+
header: {
|
|
226
|
+
...((opts === null || opts === void 0 ? void 0 : opts.chainId) && { chain_id: opts === null || opts === void 0 ? void 0 : opts.chainId }),
|
|
227
|
+
...((opts === null || opts === void 0 ? void 0 : opts.rcLimit) && { rc_limit: opts === null || opts === void 0 ? void 0 : opts.rcLimit }),
|
|
228
|
+
...((opts === null || opts === void 0 ? void 0 : opts.nonce) && { nonce: opts === null || opts === void 0 ? void 0 : opts.nonce }),
|
|
229
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payer) && { payer: opts === null || opts === void 0 ? void 0 : opts.payer }),
|
|
230
|
+
...((opts === null || opts === void 0 ? void 0 : opts.payee) && { payee: opts === null || opts === void 0 ? void 0 : opts.payee }),
|
|
231
|
+
},
|
|
232
|
+
operations: [
|
|
233
|
+
{
|
|
234
|
+
upload_contract: {
|
|
235
|
+
contract_id: (0, utils_1.encodeBase58)(operation.upload_contract.contract_id),
|
|
236
|
+
bytecode: (0, utils_1.encodeBase64url)(this.bytecode),
|
|
237
|
+
...((opts === null || opts === void 0 ? void 0 : opts.abi) && { abi: opts === null || opts === void 0 ? void 0 : opts.abi }),
|
|
238
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract) && {
|
|
239
|
+
authorizes_call_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract,
|
|
240
|
+
}),
|
|
241
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication) && {
|
|
242
|
+
authorizes_transaction_application: opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication,
|
|
243
|
+
}),
|
|
244
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract) && {
|
|
245
|
+
authorizes_upload_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract,
|
|
246
|
+
}),
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
],
|
|
196
250
|
});
|
|
197
|
-
|
|
198
|
-
|
|
251
|
+
// return result if the transaction will not be broadcasted
|
|
252
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction)) {
|
|
253
|
+
const noWait = () => {
|
|
254
|
+
throw new Error("This transaction was not broadcasted");
|
|
255
|
+
};
|
|
256
|
+
if (opts.signTransaction)
|
|
257
|
+
await this.signer.signTransaction(tx);
|
|
258
|
+
return { operation, transaction: { ...tx, wait: noWait } };
|
|
259
|
+
}
|
|
260
|
+
const { transaction, receipt } = await this.signer.sendTransaction(tx);
|
|
261
|
+
return { operation, transaction, receipt };
|
|
199
262
|
}
|
|
200
263
|
/**
|
|
201
264
|
* Encondes a contract operation using Koinos serialization
|
|
@@ -217,8 +280,8 @@ class Contract {
|
|
|
217
280
|
* // {
|
|
218
281
|
* // call_contract: {
|
|
219
282
|
* // contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
220
|
-
* // entry_point:
|
|
221
|
-
* // args: "
|
|
283
|
+
* // entry_point: 670398154,
|
|
284
|
+
* // args: "ChkAEjl6vrl55V2Oym_rzsnMxIqBoie9PHmMEhkAQgjT1UACatdFY3e5QRkyG7OAzwcCCIylGOgH",
|
|
222
285
|
* // }
|
|
223
286
|
* // }
|
|
224
287
|
* ```
|
|
@@ -239,9 +302,9 @@ class Contract {
|
|
|
239
302
|
}
|
|
240
303
|
return {
|
|
241
304
|
call_contract: {
|
|
242
|
-
contract_id: this.id,
|
|
305
|
+
contract_id: (0, utils_1.encodeBase58)(this.id),
|
|
243
306
|
entry_point: method.entryPoint,
|
|
244
|
-
args: bufferInputs,
|
|
307
|
+
args: (0, utils_1.encodeBase64url)(bufferInputs),
|
|
245
308
|
},
|
|
246
309
|
};
|
|
247
310
|
}
|
|
@@ -252,8 +315,8 @@ class Contract {
|
|
|
252
315
|
* const opDecoded = contract.decodeOperation({
|
|
253
316
|
* call_contract: {
|
|
254
317
|
* contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
255
|
-
* entry_point:
|
|
256
|
-
* args: "
|
|
318
|
+
* entry_point: 0x27f576ca,
|
|
319
|
+
* args: "ChkAEjl6vrl55V2Oym_rzsnMxIqBoie9PHmMEhkAQgjT1UACatdFY3e5QRkyG7OAzwcCCIylGOgH",
|
|
257
320
|
* }
|
|
258
321
|
* });
|
|
259
322
|
* console.log(opDecoded);
|
|
@@ -276,8 +339,8 @@ class Contract {
|
|
|
276
339
|
throw new Error("Serializer is not defined");
|
|
277
340
|
if (!op.call_contract)
|
|
278
341
|
throw new Error("Operation is not CallContractOperation");
|
|
279
|
-
if (
|
|
280
|
-
throw new Error(`Invalid contract id. Expected: ${(0, utils_1.encodeBase58)(this.id)}. Received: ${
|
|
342
|
+
if (op.call_contract.contract_id !== (0, utils_1.encodeBase58)(this.id))
|
|
343
|
+
throw new Error(`Invalid contract id. Expected: ${(0, utils_1.encodeBase58)(this.id)}. Received: ${op.call_contract.contract_id}`);
|
|
281
344
|
for (let i = 0; i < Object.keys(this.abi.methods).length; i += 1) {
|
|
282
345
|
const opName = Object.keys(this.abi.methods)[i];
|
|
283
346
|
const method = this.abi.methods[opName];
|
package/lib/Contract.js.map
CHANGED
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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tD,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;AAxaD,4BAwaC;AAED,kBAAe,QAAQ,CAAC"}
|
package/lib/Provider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockJson, TransactionJson, CallContractOperationJson } from "./interface";
|
|
1
|
+
import { BlockJson, TransactionJson, CallContractOperationJson, TransactionReceipt } from "./interface";
|
|
2
2
|
/**
|
|
3
3
|
* Class to connect with the RPC node
|
|
4
4
|
*/
|
|
@@ -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
|
|
@@ -132,12 +140,12 @@ export declare class Provider {
|
|
|
132
140
|
*
|
|
133
141
|
* When _byTransactionId_ is used it returns the block id.
|
|
134
142
|
*
|
|
135
|
-
* @param timeout - Timeout in milliseconds. By default it is
|
|
143
|
+
* @param timeout - Timeout in milliseconds. By default it is 60000
|
|
136
144
|
* @example
|
|
137
145
|
* ```ts
|
|
138
146
|
* const blockNumber = await provider.wait(txId);
|
|
139
|
-
* // const blockNumber = await provider.wait(txId, "byBlock",
|
|
140
|
-
* // const blockId = await provider.wait(txId, "byTransactionId",
|
|
147
|
+
* // const blockNumber = await provider.wait(txId, "byBlock", 60000);
|
|
148
|
+
* // const blockId = await provider.wait(txId, "byTransactionId", 60000);
|
|
141
149
|
* console.log("Transaction mined")
|
|
142
150
|
* ```
|
|
143
151
|
*/
|
|
@@ -146,7 +154,14 @@ 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<{
|
|
158
|
+
receipt: TransactionReceipt;
|
|
159
|
+
}>;
|
|
160
|
+
/**
|
|
161
|
+
* Function to call "chain.submit_block" to send a signed
|
|
162
|
+
* block to the blockchain.
|
|
163
|
+
*/
|
|
164
|
+
submitBlock(block: BlockJson): Promise<Record<string, never>>;
|
|
150
165
|
/**
|
|
151
166
|
* Function to call "chain.read_contract" to read a contract.
|
|
152
167
|
* This function is used by [[Contract]] class when read methods
|