koilib 2.6.1 → 2.7.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 +5 -5
- package/dist/koinos.js +106 -96
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +9 -11
- package/lib/Contract.js +12 -12
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +24 -17
- package/lib/Provider.js +83 -81
- package/lib/Provider.js.map +1 -1
- package/lib/Signer.d.ts +4 -4
- package/lib/Signer.js +11 -3
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +9 -11
- package/lib/browser/Contract.js +12 -12
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +24 -17
- package/lib/browser/Provider.js +83 -81
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Signer.d.ts +4 -4
- package/lib/browser/Signer.js +11 -3
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/interface.d.ts +22 -21
- package/lib/interface.d.ts +22 -21
- package/package.json +1 -1
package/lib/browser/Contract.js
CHANGED
|
@@ -41,15 +41,15 @@ const utils_1 = require("./utils");
|
|
|
41
41
|
* console.log(result)
|
|
42
42
|
*
|
|
43
43
|
* // Transfer
|
|
44
|
-
* const { transaction
|
|
44
|
+
* const { transaction } = await koin.transfer({
|
|
45
45
|
* to: "172AB1FgCsYrRAW5cwQ8KjadgxofvgPFd6",
|
|
46
46
|
* value: "10.0001",
|
|
47
47
|
* });
|
|
48
48
|
* console.log(`Transaction id ${transaction.id} submitted`);
|
|
49
49
|
*
|
|
50
50
|
* // wait to be mined
|
|
51
|
-
* const
|
|
52
|
-
* console.log(`Transaction mined. Block
|
|
51
|
+
* const blockNumber = await transaction.wait();
|
|
52
|
+
* console.log(`Transaction mined. Block number: ${blockNumber}`);
|
|
53
53
|
* }
|
|
54
54
|
*
|
|
55
55
|
* main();
|
|
@@ -127,7 +127,7 @@ class Contract {
|
|
|
127
127
|
// write contract (sign and send)
|
|
128
128
|
if (!this.signer)
|
|
129
129
|
throw new Error("signer not found");
|
|
130
|
-
const
|
|
130
|
+
const tx = await this.signer.encodeTransaction({
|
|
131
131
|
...opts,
|
|
132
132
|
operations: [operation],
|
|
133
133
|
});
|
|
@@ -136,8 +136,8 @@ class Contract {
|
|
|
136
136
|
const contractId = (0, utils_1.encodeBase58)(this.id);
|
|
137
137
|
abis[contractId] = this.abi;
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
return { operation, transaction
|
|
139
|
+
const transaction = await this.signer.sendTransaction(tx, abis);
|
|
140
|
+
return { operation, transaction };
|
|
141
141
|
};
|
|
142
142
|
});
|
|
143
143
|
}
|
|
@@ -166,10 +166,10 @@ class Contract {
|
|
|
166
166
|
* const signer = new Signer({ privateKey, provider });
|
|
167
167
|
* const bytecode = new Uint8Array([1, 2, 3, 4]);
|
|
168
168
|
* const contract = new Contract({ signer, provider, bytecode });
|
|
169
|
-
* const {
|
|
169
|
+
* const { transaction } = await contract.deploy();
|
|
170
170
|
* // wait to be mined
|
|
171
|
-
* const
|
|
172
|
-
* console.log(`Contract uploaded in block
|
|
171
|
+
* const blockNumber = await transaction.wait();
|
|
172
|
+
* console.log(`Contract uploaded in block number ${blockNumber}`);
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
175
|
async deploy(options) {
|
|
@@ -190,12 +190,12 @@ class Contract {
|
|
|
190
190
|
// return operation if send is false
|
|
191
191
|
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction))
|
|
192
192
|
return { operation };
|
|
193
|
-
const
|
|
193
|
+
const tx = await this.signer.encodeTransaction({
|
|
194
194
|
...opts,
|
|
195
195
|
operations: [operation],
|
|
196
196
|
});
|
|
197
|
-
const
|
|
198
|
-
return { operation, transaction
|
|
197
|
+
const transaction = await this.signer.sendTransaction(tx);
|
|
198
|
+
return { operation, transaction };
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* Encondes a contract operation using Koinos serialization
|
|
@@ -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;AAS1C,mCAAmE;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAa,QAAQ;IA4DnB,YAAY,CAcX;;QACC,IAAI,CAAC,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,GAAG,IAAA,oBAAY,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,KAAI,MAAA,CAAC,CAAC,MAAM,0CAAE,QAAQ,CAAA,CAAC;QACjD,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC3B,IAAI,CAAC,CAAC,UAAU,EAAE;YAChB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;SAChC;aAAM,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC/C;QACD,IAAI,CAAC,OAAO,GAAG;YACb,QAAQ,EAAE,GAAG;YACb,eAAe,EAAE,IAAI;YACrB,QAAQ,EAAE,IAAI;YACd,GAAG,CAAC,CAAC,OAAO;SACb,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAEpB,IACE,IAAI,CAAC,MAAM;YACX,IAAI,CAAC,QAAQ;YACb,IA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ACtD,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;AArVD,4BAqVC;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockJson, TransactionJson, CallContractOperationJson
|
|
1
|
+
import { BlockJson, TransactionJson, CallContractOperationJson } from "./interface";
|
|
2
2
|
/**
|
|
3
3
|
* Class to connect with the RPC node
|
|
4
4
|
*/
|
|
@@ -119,27 +119,34 @@ export declare class Provider {
|
|
|
119
119
|
};
|
|
120
120
|
}>;
|
|
121
121
|
/**
|
|
122
|
-
* Function to
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
122
|
+
* Function to wait for a transaction to be mined.
|
|
123
|
+
* @param txId - transaction id
|
|
124
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
125
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
126
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
127
|
+
* microservice to search the transaction by its id. If non of them is
|
|
128
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
129
|
+
* requires the transaction store, which is an optional microservice).
|
|
130
|
+
*
|
|
131
|
+
* When _byBlock_ is used it returns the block number.
|
|
132
|
+
*
|
|
133
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
134
|
+
*
|
|
135
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
127
136
|
* @example
|
|
128
137
|
* ```ts
|
|
129
|
-
* const
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* signatureData: "...",
|
|
133
|
-
* });
|
|
134
|
-
* console.log("Transaction submitted to the mempool");
|
|
135
|
-
* // wait to be mined
|
|
136
|
-
* const blockNumber = await transactionResponse.wait();
|
|
137
|
-
* // const blockNumber = await transactionResponse.wait("byBlock", 30000);
|
|
138
|
-
* // const blockId = await transactionResponse.wait("byTransactionId", 30000);
|
|
138
|
+
* const blockNumber = await provider.wait(txId);
|
|
139
|
+
* // const blockNumber = await provider.wait(txId, "byBlock", 30000);
|
|
140
|
+
* // const blockId = await provider.wait(txId, "byTransactionId", 30000);
|
|
139
141
|
* console.log("Transaction mined")
|
|
140
142
|
* ```
|
|
141
143
|
*/
|
|
142
|
-
|
|
144
|
+
wait(txId: string, type?: "byTransactionId" | "byBlock", timeout?: number): Promise<string | number>;
|
|
145
|
+
/**
|
|
146
|
+
* Function to call "chain.submit_transaction" to send a signed
|
|
147
|
+
* transaction to the blockchain.
|
|
148
|
+
*/
|
|
149
|
+
sendTransaction(transaction: TransactionJson): Promise<{}>;
|
|
143
150
|
/**
|
|
144
151
|
* Function to call "chain.read_contract" to read a contract.
|
|
145
152
|
* This function is used by [[Contract]] class when read methods
|
package/lib/browser/Provider.js
CHANGED
|
@@ -142,93 +142,95 @@ class Provider {
|
|
|
142
142
|
return (await this.getBlocks(height, 1))[0];
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
|
-
* Function to
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
145
|
+
* Function to wait for a transaction to be mined.
|
|
146
|
+
* @param txId - transaction id
|
|
147
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
148
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
149
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
150
|
+
* microservice to search the transaction by its id. If non of them is
|
|
151
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
152
|
+
* requires the transaction store, which is an optional microservice).
|
|
153
|
+
*
|
|
154
|
+
* When _byBlock_ is used it returns the block number.
|
|
155
|
+
*
|
|
156
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
157
|
+
*
|
|
158
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
150
159
|
* @example
|
|
151
160
|
* ```ts
|
|
152
|
-
* const
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* signatureData: "...",
|
|
156
|
-
* });
|
|
157
|
-
* console.log("Transaction submitted to the mempool");
|
|
158
|
-
* // wait to be mined
|
|
159
|
-
* const blockNumber = await transactionResponse.wait();
|
|
160
|
-
* // const blockNumber = await transactionResponse.wait("byBlock", 30000);
|
|
161
|
-
* // const blockId = await transactionResponse.wait("byTransactionId", 30000);
|
|
161
|
+
* const blockNumber = await provider.wait(txId);
|
|
162
|
+
* // const blockNumber = await provider.wait(txId, "byBlock", 30000);
|
|
163
|
+
* // const blockId = await provider.wait(txId, "byTransactionId", 30000);
|
|
162
164
|
* console.log("Transaction mined")
|
|
163
165
|
* ```
|
|
164
166
|
*/
|
|
165
|
-
async
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (tx)
|
|
195
|
-
bNum = Number(block.block_height);
|
|
196
|
-
});
|
|
197
|
-
const lastId = blocks[blocks.length - 1].block_id;
|
|
198
|
-
return [bNum, lastId];
|
|
199
|
-
};
|
|
200
|
-
let blockNumber = 0;
|
|
201
|
-
let iniBlock = 0;
|
|
202
|
-
let previousId = "";
|
|
203
|
-
while (Date.now() < iniTime + timeout) {
|
|
204
|
-
await sleep(1000);
|
|
205
|
-
const { head_topology: headTopology } = await this.getHeadInfo();
|
|
206
|
-
if (blockNumber === 0) {
|
|
207
|
-
blockNumber = Number(headTopology.height);
|
|
208
|
-
iniBlock = blockNumber;
|
|
209
|
-
}
|
|
210
|
-
if (Number(headTopology.height) === blockNumber - 1 &&
|
|
211
|
-
previousId &&
|
|
212
|
-
previousId !== headTopology.id) {
|
|
213
|
-
const [bNum, lastId] = await findTxInBlocks(iniBlock, Number(headTopology.height) - iniBlock + 1, headTopology.id);
|
|
214
|
-
if (bNum)
|
|
215
|
-
return bNum;
|
|
216
|
-
previousId = lastId;
|
|
217
|
-
blockNumber = Number(headTopology.height) + 1;
|
|
218
|
-
}
|
|
219
|
-
// eslint-disable-next-line no-continue
|
|
220
|
-
if (blockNumber > Number(headTopology.height))
|
|
221
|
-
continue;
|
|
222
|
-
const [bNum, lastId] = await findTxInBlocks(blockNumber, 1, headTopology.id);
|
|
223
|
-
if (bNum)
|
|
224
|
-
return bNum;
|
|
225
|
-
if (!previousId)
|
|
226
|
-
previousId = lastId;
|
|
227
|
-
blockNumber += 1;
|
|
228
|
-
}
|
|
229
|
-
throw new Error(`Transaction not mined after ${timeout} ms. Blocks checked from ${iniBlock} to ${blockNumber}`);
|
|
230
|
-
},
|
|
167
|
+
async wait(txId, type = "byBlock", timeout = 30000) {
|
|
168
|
+
const iniTime = Date.now();
|
|
169
|
+
if (type === "byTransactionId") {
|
|
170
|
+
while (Date.now() < iniTime + timeout) {
|
|
171
|
+
await sleep(1000);
|
|
172
|
+
const { transactions } = await this.getTransactionsById([txId]);
|
|
173
|
+
if (transactions &&
|
|
174
|
+
transactions[0] &&
|
|
175
|
+
transactions[0].containing_blocks)
|
|
176
|
+
return transactions[0].containing_blocks[0];
|
|
177
|
+
}
|
|
178
|
+
throw new Error(`Transaction not mined after ${timeout} ms`);
|
|
179
|
+
}
|
|
180
|
+
// byBlock
|
|
181
|
+
const findTxInBlocks = async (ini, numBlocks, idRef) => {
|
|
182
|
+
const blocks = await this.getBlocks(ini, numBlocks, idRef);
|
|
183
|
+
let bNum = 0;
|
|
184
|
+
blocks.forEach((block) => {
|
|
185
|
+
if (!block ||
|
|
186
|
+
!block.block ||
|
|
187
|
+
!block.block_id ||
|
|
188
|
+
!block.block.transactions)
|
|
189
|
+
return;
|
|
190
|
+
const tx = block.block.transactions.find((t) => t.id === txId);
|
|
191
|
+
if (tx)
|
|
192
|
+
bNum = Number(block.block_height);
|
|
193
|
+
});
|
|
194
|
+
const lastId = blocks[blocks.length - 1].block_id;
|
|
195
|
+
return [bNum, lastId];
|
|
231
196
|
};
|
|
197
|
+
let blockNumber = 0;
|
|
198
|
+
let iniBlock = 0;
|
|
199
|
+
let previousId = "";
|
|
200
|
+
while (Date.now() < iniTime + timeout) {
|
|
201
|
+
await sleep(1000);
|
|
202
|
+
const { head_topology: headTopology } = await this.getHeadInfo();
|
|
203
|
+
if (blockNumber === 0) {
|
|
204
|
+
blockNumber = Number(headTopology.height);
|
|
205
|
+
iniBlock = blockNumber;
|
|
206
|
+
}
|
|
207
|
+
if (Number(headTopology.height) === blockNumber - 1 &&
|
|
208
|
+
previousId &&
|
|
209
|
+
previousId !== headTopology.id) {
|
|
210
|
+
const [bNum, lastId] = await findTxInBlocks(iniBlock, Number(headTopology.height) - iniBlock + 1, headTopology.id);
|
|
211
|
+
if (bNum)
|
|
212
|
+
return bNum;
|
|
213
|
+
previousId = lastId;
|
|
214
|
+
blockNumber = Number(headTopology.height) + 1;
|
|
215
|
+
}
|
|
216
|
+
// eslint-disable-next-line no-continue
|
|
217
|
+
if (blockNumber > Number(headTopology.height))
|
|
218
|
+
continue;
|
|
219
|
+
const [bNum, lastId] = await findTxInBlocks(blockNumber, 1, headTopology.id);
|
|
220
|
+
if (bNum)
|
|
221
|
+
return bNum;
|
|
222
|
+
if (!previousId)
|
|
223
|
+
previousId = lastId;
|
|
224
|
+
blockNumber += 1;
|
|
225
|
+
}
|
|
226
|
+
throw new Error(`Transaction not mined after ${timeout} ms. Blocks checked from ${iniBlock} to ${blockNumber}`);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Function to call "chain.submit_transaction" to send a signed
|
|
230
|
+
* transaction to the blockchain.
|
|
231
|
+
*/
|
|
232
|
+
async sendTransaction(transaction) {
|
|
233
|
+
return this.call("chain.submit_transaction", { transaction });
|
|
232
234
|
}
|
|
233
235
|
/**
|
|
234
236
|
* Function to call "chain.read_contract" to read a contract.
|
|
@@ -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":";;;AAMA,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,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAc,MAAc,EAAE,MAAe;QACrD,qCAAqC;QACrC,iDAAiD;QACjD,OAAO,IAAI,EAAE;YACX,IAAI;gBACF,MAAM,IAAI,GAAG;oBACX,EAAE,EAAE,IAAI,CAAC,K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M,cAAc,CACzC,QAAQ,EACR,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,QAAQ,GAAG,CAAC,EAC1C,YAAY,CAAC,EAAE,CAChB,CAAC;gBACF,IAAI,IAAI;oBAAE,OAAO,IAAI,CAAC;gBACtB,UAAU,GAAG,MAAM,CAAC;gBACpB,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC/C;YACD,uCAAuC;YACvC,IAAI,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC;gBAAE,SAAS;YACxD,MAAM,CAAC,IAAI,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,CAAC,WAA4B;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,SAAoC;QAIrD,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;CACF;AArXD,4BAqXC;AAED,kBAAe,QAAQ,CAAC"}
|
package/lib/browser/Signer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Provider } from "./Provider";
|
|
2
|
-
import { TransactionJson, ActiveTransactionData, Abi,
|
|
2
|
+
import { TransactionJson, TransactionJsonWait, ActiveTransactionData, Abi, RecoverPublicKeyOptions, BlockJson } from "./interface";
|
|
3
3
|
import { Serializer } from "./Serializer";
|
|
4
4
|
export interface SignerInterface {
|
|
5
5
|
provider?: Provider;
|
|
@@ -7,7 +7,7 @@ export interface SignerInterface {
|
|
|
7
7
|
getAddress: (compressed?: boolean) => string;
|
|
8
8
|
getPrivateKey: (format: "wif" | "hex", compressed?: boolean) => string;
|
|
9
9
|
signTransaction: (tx: TransactionJson) => Promise<TransactionJson>;
|
|
10
|
-
sendTransaction: (tx: TransactionJson, abis?: Record<string, Abi>) => Promise<
|
|
10
|
+
sendTransaction: (tx: TransactionJson, abis?: Record<string, Abi>) => Promise<TransactionJsonWait>;
|
|
11
11
|
encodeTransaction: (activeData: ActiveTransactionData) => Promise<TransactionJson>;
|
|
12
12
|
decodeTransaction: (tx: TransactionJson) => Promise<ActiveTransactionData>;
|
|
13
13
|
}
|
|
@@ -179,7 +179,7 @@ export declare class Signer implements SignerInterface {
|
|
|
179
179
|
* transaction. This parameter is optional.
|
|
180
180
|
* @returns
|
|
181
181
|
*/
|
|
182
|
-
sendTransaction(tx: TransactionJson, _abis?: Record<string, Abi>): Promise<
|
|
182
|
+
sendTransaction(tx: TransactionJson, _abis?: Record<string, Abi>): Promise<TransactionJsonWait>;
|
|
183
183
|
/**
|
|
184
184
|
* Function to recover the public key from a signed
|
|
185
185
|
* transaction or block.
|
|
@@ -283,7 +283,7 @@ export declare class Signer implements SignerInterface {
|
|
|
283
283
|
* Function to encode a transaction
|
|
284
284
|
* @param activeData - Active data consists of nonce, rc_limit, and
|
|
285
285
|
* operations. Do not set the nonce to get it from the blockchain
|
|
286
|
-
* using the provider. The rc_limit is
|
|
286
|
+
* using the provider. The rc_limit is 1e8 by default.
|
|
287
287
|
* @returns A transaction encoded. The active field is encoded in
|
|
288
288
|
* base64url
|
|
289
289
|
*/
|
package/lib/browser/Signer.js
CHANGED
|
@@ -247,7 +247,15 @@ class Signer {
|
|
|
247
247
|
await this.signTransaction(tx);
|
|
248
248
|
if (!this.provider)
|
|
249
249
|
throw new Error("provider is undefined");
|
|
250
|
-
|
|
250
|
+
await this.provider.sendTransaction(tx);
|
|
251
|
+
return {
|
|
252
|
+
...tx,
|
|
253
|
+
wait: async (type = "byBlock", timeout = 30000) => {
|
|
254
|
+
if (!this.provider)
|
|
255
|
+
throw new Error("provider is undefined");
|
|
256
|
+
return this.provider.wait(tx.id, type, timeout);
|
|
257
|
+
},
|
|
258
|
+
};
|
|
251
259
|
}
|
|
252
260
|
/**
|
|
253
261
|
* Function to recover the public key from a signed
|
|
@@ -382,7 +390,7 @@ class Signer {
|
|
|
382
390
|
* Function to encode a transaction
|
|
383
391
|
* @param activeData - Active data consists of nonce, rc_limit, and
|
|
384
392
|
* operations. Do not set the nonce to get it from the blockchain
|
|
385
|
-
* using the provider. The rc_limit is
|
|
393
|
+
* using the provider. The rc_limit is 1e8 by default.
|
|
386
394
|
* @returns A transaction encoded. The active field is encoded in
|
|
387
395
|
* base64url
|
|
388
396
|
*/
|
|
@@ -395,7 +403,7 @@ class Signer {
|
|
|
395
403
|
// this depends on the final architecture for names on Koinos
|
|
396
404
|
nonce = await this.provider.getNonce(this.getAddress());
|
|
397
405
|
}
|
|
398
|
-
const rcLimit = activeData.rc_limit === undefined ?
|
|
406
|
+
const rcLimit = activeData.rc_limit === undefined ? 1e8 : activeData.rc_limit;
|
|
399
407
|
const operations = activeData.operations ? activeData.operations : [];
|
|
400
408
|
const activeData2 = {
|
|
401
409
|
rc_limit: rcLimit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Signer.js","sourceRoot":"","sources":["../../src/Signer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,iDAA8C;AAC9C,uDAAyC;AAUzC,gGAAiE;AACjE,mCAQiB;AACjB,6CAA0C;AAkB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAa,MAAM;IA0BjB;;;;;;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,GACX,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;QAChE,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QAEtE,MAAM,WAAW,GAA0B;YACzC,QAAQ,EAAE,OAAO;YACjB,KAAK;YACL,UAAU;SACX,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAE7D,OAAO;YACL,MAAM,EAAE,IAAA,oBAAY,EAAC,MAAM,CAAC;SACV,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAC,EAAmB;QACzC,IAAI,CAAC,EAAE,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,UAAW,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACF;AAjZD,wBAiZC;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -132,27 +132,25 @@ export interface RecoverPublicKeyOptions {
|
|
|
132
132
|
*/
|
|
133
133
|
transformSignature?: (signatureData: string) => Promise<string>;
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
wait: (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
155
|
-
}
|
|
135
|
+
/**
|
|
136
|
+
* Function to wait for a transaction to be mined.
|
|
137
|
+
* This function comes as a response after sending a transaction.
|
|
138
|
+
* See [[Provider.sendTransaction]]
|
|
139
|
+
*
|
|
140
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
141
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
142
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
143
|
+
* microservice to search the transaction by its id. If non of them is
|
|
144
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
145
|
+
* requires the transaction store, which is an optional microservice).
|
|
146
|
+
*
|
|
147
|
+
* When _byBlock_ is used it returns the block number.
|
|
148
|
+
*
|
|
149
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
150
|
+
*
|
|
151
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
152
|
+
*/
|
|
153
|
+
export declare type WaitFunction = (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
156
154
|
export interface UploadContractOperation {
|
|
157
155
|
contract_id?: Uint8Array;
|
|
158
156
|
bytecode?: Uint8Array;
|
|
@@ -261,6 +259,9 @@ export interface TransactionJson {
|
|
|
261
259
|
*/
|
|
262
260
|
signature_data?: string;
|
|
263
261
|
}
|
|
262
|
+
export interface TransactionJsonWait extends TransactionJson {
|
|
263
|
+
wait: WaitFunction;
|
|
264
|
+
}
|
|
264
265
|
export interface BlockHeaderJson {
|
|
265
266
|
previous?: string;
|
|
266
267
|
height?: string;
|
package/lib/interface.d.ts
CHANGED
|
@@ -132,27 +132,25 @@ export interface RecoverPublicKeyOptions {
|
|
|
132
132
|
*/
|
|
133
133
|
transformSignature?: (signatureData: string) => Promise<string>;
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
wait: (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
155
|
-
}
|
|
135
|
+
/**
|
|
136
|
+
* Function to wait for a transaction to be mined.
|
|
137
|
+
* This function comes as a response after sending a transaction.
|
|
138
|
+
* See [[Provider.sendTransaction]]
|
|
139
|
+
*
|
|
140
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
141
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
142
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
143
|
+
* microservice to search the transaction by its id. If non of them is
|
|
144
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
145
|
+
* requires the transaction store, which is an optional microservice).
|
|
146
|
+
*
|
|
147
|
+
* When _byBlock_ is used it returns the block number.
|
|
148
|
+
*
|
|
149
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
150
|
+
*
|
|
151
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
152
|
+
*/
|
|
153
|
+
export declare type WaitFunction = (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
156
154
|
export interface UploadContractOperation {
|
|
157
155
|
contract_id?: Uint8Array;
|
|
158
156
|
bytecode?: Uint8Array;
|
|
@@ -261,6 +259,9 @@ export interface TransactionJson {
|
|
|
261
259
|
*/
|
|
262
260
|
signature_data?: string;
|
|
263
261
|
}
|
|
262
|
+
export interface TransactionJsonWait extends TransactionJson {
|
|
263
|
+
wait: WaitFunction;
|
|
264
|
+
}
|
|
264
265
|
export interface BlockHeaderJson {
|
|
265
266
|
previous?: string;
|
|
266
267
|
height?: string;
|