koilib 4.0.0 → 4.1.2
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/dist/koinos.js +28 -32
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +2 -2
- package/lib/Contract.js +20 -24
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +5 -2
- package/lib/Provider.js +7 -1
- package/lib/Provider.js.map +1 -1
- package/lib/Signer.js +1 -7
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +2 -2
- package/lib/browser/Contract.js +20 -24
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +5 -2
- package/lib/browser/Provider.js +7 -1
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Signer.js +1 -7
- package/lib/browser/Signer.js.map +1 -1
- package/package.json +1 -1
package/dist/koinos.js
CHANGED
|
@@ -9892,7 +9892,7 @@ class Contract {
|
|
|
9892
9892
|
// write contract (sign and send)
|
|
9893
9893
|
if (!this.signer)
|
|
9894
9894
|
throw new Error("signer not found");
|
|
9895
|
-
|
|
9895
|
+
let tx = await this.signer.prepareTransaction({
|
|
9896
9896
|
header: {
|
|
9897
9897
|
...((opts === null || opts === void 0 ? void 0 : opts.chainId) && { chain_id: opts === null || opts === void 0 ? void 0 : opts.chainId }),
|
|
9898
9898
|
...((opts === null || opts === void 0 ? void 0 : opts.rcLimit) && { rc_limit: opts === null || opts === void 0 ? void 0 : opts.rcLimit }),
|
|
@@ -9913,7 +9913,7 @@ class Contract {
|
|
|
9913
9913
|
throw new Error("This transaction was not broadcasted");
|
|
9914
9914
|
};
|
|
9915
9915
|
if (opts.signTransaction)
|
|
9916
|
-
await this.signer.signTransaction(tx, abis);
|
|
9916
|
+
tx = await this.signer.signTransaction(tx, abis);
|
|
9917
9917
|
return { operation, transaction: { ...tx, wait: noWait } };
|
|
9918
9918
|
}
|
|
9919
9919
|
const { transaction, receipt } = await this.signer.sendTransaction(tx, abis);
|
|
@@ -9982,13 +9982,26 @@ class Contract {
|
|
|
9982
9982
|
...this.options,
|
|
9983
9983
|
...options,
|
|
9984
9984
|
};
|
|
9985
|
+
const contractId = this.id
|
|
9986
|
+
? (0, utils_1.encodeBase58)(this.id)
|
|
9987
|
+
: this.signer.getAddress();
|
|
9985
9988
|
const operation = {
|
|
9986
9989
|
upload_contract: {
|
|
9987
|
-
contract_id:
|
|
9988
|
-
bytecode: this.bytecode,
|
|
9990
|
+
contract_id: contractId,
|
|
9991
|
+
bytecode: (0, utils_1.encodeBase64url)(this.bytecode),
|
|
9992
|
+
...((opts === null || opts === void 0 ? void 0 : opts.abi) && { abi: opts === null || opts === void 0 ? void 0 : opts.abi }),
|
|
9993
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract) && {
|
|
9994
|
+
authorizes_call_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract,
|
|
9995
|
+
}),
|
|
9996
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication) && {
|
|
9997
|
+
authorizes_transaction_application: opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication,
|
|
9998
|
+
}),
|
|
9999
|
+
...((opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract) && {
|
|
10000
|
+
authorizes_upload_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract,
|
|
10001
|
+
}),
|
|
9989
10002
|
},
|
|
9990
10003
|
};
|
|
9991
|
-
|
|
10004
|
+
let tx = await this.signer.prepareTransaction({
|
|
9992
10005
|
header: {
|
|
9993
10006
|
...((opts === null || opts === void 0 ? void 0 : opts.chainId) && { chain_id: opts === null || opts === void 0 ? void 0 : opts.chainId }),
|
|
9994
10007
|
...((opts === null || opts === void 0 ? void 0 : opts.rcLimit) && { rc_limit: opts === null || opts === void 0 ? void 0 : opts.rcLimit }),
|
|
@@ -9996,24 +10009,7 @@ class Contract {
|
|
|
9996
10009
|
...((opts === null || opts === void 0 ? void 0 : opts.payer) && { payer: opts === null || opts === void 0 ? void 0 : opts.payer }),
|
|
9997
10010
|
...((opts === null || opts === void 0 ? void 0 : opts.payee) && { payee: opts === null || opts === void 0 ? void 0 : opts.payee }),
|
|
9998
10011
|
},
|
|
9999
|
-
operations: [
|
|
10000
|
-
{
|
|
10001
|
-
upload_contract: {
|
|
10002
|
-
contract_id: (0, utils_1.encodeBase58)(operation.upload_contract.contract_id),
|
|
10003
|
-
bytecode: (0, utils_1.encodeBase64url)(this.bytecode),
|
|
10004
|
-
...((opts === null || opts === void 0 ? void 0 : opts.abi) && { abi: opts === null || opts === void 0 ? void 0 : opts.abi }),
|
|
10005
|
-
...((opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract) && {
|
|
10006
|
-
authorizes_call_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesCallContract,
|
|
10007
|
-
}),
|
|
10008
|
-
...((opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication) && {
|
|
10009
|
-
authorizes_transaction_application: opts === null || opts === void 0 ? void 0 : opts.authorizesTransactionApplication,
|
|
10010
|
-
}),
|
|
10011
|
-
...((opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract) && {
|
|
10012
|
-
authorizes_upload_contract: opts === null || opts === void 0 ? void 0 : opts.authorizesUploadContract,
|
|
10013
|
-
}),
|
|
10014
|
-
},
|
|
10015
|
-
},
|
|
10016
|
-
],
|
|
10012
|
+
operations: [operation],
|
|
10017
10013
|
});
|
|
10018
10014
|
// return result if the transaction will not be broadcasted
|
|
10019
10015
|
if (!(opts === null || opts === void 0 ? void 0 : opts.sendTransaction)) {
|
|
@@ -10021,7 +10017,7 @@ class Contract {
|
|
|
10021
10017
|
throw new Error("This transaction was not broadcasted");
|
|
10022
10018
|
};
|
|
10023
10019
|
if (opts.signTransaction)
|
|
10024
|
-
await this.signer.signTransaction(tx);
|
|
10020
|
+
tx = await this.signer.signTransaction(tx);
|
|
10025
10021
|
return { operation, transaction: { ...tx, wait: noWait } };
|
|
10026
10022
|
}
|
|
10027
10023
|
const { transaction, receipt } = await this.signer.sendTransaction(tx);
|
|
@@ -10395,9 +10391,15 @@ class Provider {
|
|
|
10395
10391
|
/**
|
|
10396
10392
|
* Function to call "chain.submit_transaction" to send a signed
|
|
10397
10393
|
* transaction to the blockchain.
|
|
10394
|
+
* @returns It returns the receipt received from the RPC node
|
|
10395
|
+
* and the transaction with the arrow function "wait" (see [[wait]])
|
|
10398
10396
|
*/
|
|
10399
10397
|
async sendTransaction(transaction) {
|
|
10400
|
-
|
|
10398
|
+
const response = await this.call("chain.submit_transaction", { transaction });
|
|
10399
|
+
transaction.wait = async (type = "byBlock", timeout = 60000) => {
|
|
10400
|
+
return this.wait(transaction.id, type, timeout);
|
|
10401
|
+
};
|
|
10402
|
+
return { ...response, transaction: transaction };
|
|
10401
10403
|
}
|
|
10402
10404
|
/**
|
|
10403
10405
|
* Function to call "chain.submit_block" to send a signed
|
|
@@ -10961,13 +10963,7 @@ class Signer {
|
|
|
10961
10963
|
tx = await this.signTransaction(tx);
|
|
10962
10964
|
if (!this.provider)
|
|
10963
10965
|
throw new Error("provider is undefined");
|
|
10964
|
-
|
|
10965
|
-
tx.wait = async (type = "byBlock", timeout = 60000) => {
|
|
10966
|
-
if (!this.provider)
|
|
10967
|
-
throw new Error("provider is undefined");
|
|
10968
|
-
return this.provider.wait(tx.id, type, timeout);
|
|
10969
|
-
};
|
|
10970
|
-
return { receipt, transaction: tx };
|
|
10966
|
+
return this.provider.sendTransaction(tx);
|
|
10971
10967
|
}
|
|
10972
10968
|
/**
|
|
10973
10969
|
* Function to recover the public key from hash and signature
|