stellar-base
Advanced tools
Comparing version 10.0.0-soroban.4 to 10.0.0-soroban.5
@@ -29,5 +29,3 @@ "use strict"; | ||
* @param {string} contractId - ID of the contract (ex. | ||
* `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`, or as a | ||
* 32-byte hex string | ||
* `000000000000000000000000000000000000000000000000000000000000000001`). | ||
* `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`). | ||
*/ | ||
@@ -42,9 +40,3 @@ // TODO: Support contract deployment, maybe? | ||
} catch (_) { | ||
// If that fails, try it as a hex string | ||
// TODO: Add methods based on the contractSpec (or do that elsewhere?) | ||
var b = Buffer.from(contractId, 'hex'); | ||
if (b.length !== 32) { | ||
throw new Error('Invalid contract ID'); | ||
} | ||
this._id = b; | ||
throw new Error("Invalid contract ID: ".concat(contractId)); | ||
} | ||
@@ -54,5 +46,4 @@ } | ||
/** | ||
* Returns Stellar contract ID as a strkey, or hex string, ex. | ||
* `000000000000000000000000000000000000000000000000000000000000000001`. | ||
* @param {'hex'|'strkey'} format - format of output, defaults to 'strkey' | ||
* Returns Stellar contract ID as a strkey, ex. | ||
* `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`. | ||
* @returns {string} | ||
@@ -63,11 +54,3 @@ */ | ||
value: function contractId() { | ||
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'strkey'; | ||
switch (format) { | ||
case 'strkey': | ||
return _strkey.StrKey.encodeContract(this._id); | ||
case 'hex': | ||
return this._id.toString('hex'); | ||
default: | ||
throw new Error("Invalid format: ".concat(format)); | ||
} | ||
return _strkey.StrKey.encodeContract(this._id); | ||
} | ||
@@ -74,0 +57,0 @@ |
@@ -32,3 +32,2 @@ "use strict"; | ||
Account: true, | ||
Contract: true, | ||
MuxedAccount: true, | ||
@@ -42,3 +41,5 @@ Claimant: true, | ||
extractBaseAddress: true, | ||
encodeMuxedAccount: true | ||
encodeMuxedAccount: true, | ||
Contract: true, | ||
Address: true | ||
}; | ||
@@ -51,2 +52,8 @@ Object.defineProperty(exports, "Account", { | ||
}); | ||
Object.defineProperty(exports, "Address", { | ||
enumerable: true, | ||
get: function get() { | ||
return _address.Address; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Asset", { | ||
@@ -285,15 +292,2 @@ enumerable: true, | ||
var _account = require("./account"); | ||
var _address = require("./address"); | ||
Object.keys(_address).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _address[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _address[key]; | ||
} | ||
}); | ||
}); | ||
var _contract = require("./contract"); | ||
var _muxed_account = require("./muxed_account"); | ||
@@ -305,11 +299,13 @@ var _claimant = require("./claimant"); | ||
var _decode_encode_muxed_account = require("./util/decode_encode_muxed_account"); | ||
var _index = require("./numbers/index"); | ||
Object.keys(_index).forEach(function (key) { | ||
var _contract = require("./contract"); | ||
var _address = require("./address"); | ||
var _numbers = require("./numbers"); | ||
Object.keys(_numbers).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _index[key]) return; | ||
if (key in exports && exports[key] === _numbers[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _index[key]; | ||
return _numbers[key]; | ||
} | ||
@@ -330,2 +326,38 @@ }); | ||
}); | ||
var _events = require("./events"); | ||
Object.keys(_events).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _events[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _events[key]; | ||
} | ||
}); | ||
}); | ||
var _sorobandata_builder = require("./sorobandata_builder"); | ||
Object.keys(_sorobandata_builder).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _sorobandata_builder[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _sorobandata_builder[key]; | ||
} | ||
}); | ||
}); | ||
var _auth = require("./auth"); | ||
Object.keys(_auth).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _auth[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _auth[key]; | ||
} | ||
}); | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -335,3 +367,7 @@ /* eslint-disable import/no-import-module-exports */ | ||
_bignumber["default"].DEBUG = true; // gives us exceptions on bad constructor values | ||
// | ||
// Soroban | ||
// | ||
var _default = module.exports; | ||
exports["default"] = _default; |
@@ -11,3 +11,6 @@ "use strict"; | ||
* * `Networks.TESTNET`: `Test SDF Network ; September 2015` | ||
* @type {{PUBLIC: string, TESTNET: string}} | ||
* * `Networks.FUTURENET`: `Test SDF Future Network ; October 2022` | ||
* * `Networks.STANDALONE`: `Standalone Network ; February 2017` | ||
* | ||
* @type {{PUBLIC: string, TESTNET: string, FUTURENET: string, STANDALONE: string }} | ||
*/ | ||
@@ -14,0 +17,0 @@ var Networks = { |
@@ -56,3 +56,2 @@ "use strict"; | ||
* @example | ||
* ```js | ||
* let scv = contract.call("add", x, y); // assume it returns an xdr.ScVal | ||
@@ -63,3 +62,2 @@ * let bigi = scValToBigInt(scv); | ||
* new XdrLargeInt('i128', bigi); // if you do | ||
* ``` | ||
* | ||
@@ -66,0 +64,0 @@ * @param {xdr.ScVal} scv - the raw XDR value to parse into an integer |
@@ -29,7 +29,6 @@ "use strict"; | ||
* example, you have a series of encoded 32-bit integers that represent a larger | ||
* value), you can use the lower level abstraction {@link XdrLargeInt}. For example, | ||
* you could do `new XdrLargeInt('u128', bytes...).toBigInt()`. | ||
* value), you can use the lower level abstraction {@link XdrLargeInt}. For | ||
* example, you could do `new XdrLargeInt('u128', bytes...).toBigInt()`. | ||
* | ||
* @example | ||
* ```js | ||
* import sdk from "stellar-base"; | ||
@@ -75,3 +74,2 @@ * | ||
* const scv = i.toI64(); | ||
* ``` | ||
* | ||
@@ -78,0 +76,0 @@ * @param {number|bigint|string|ScInt} value - a single, integer-like value |
@@ -22,2 +22,15 @@ "use strict"; | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint no-bitwise: ["error", {"allow": [">>"]}] */ | ||
/** | ||
* A wrapper class to represent large XDR-encodable integers. | ||
* | ||
* This operates at a lower level than {@link ScInt} by forcing you to specify | ||
* the type / width / size in bits of the integer you're targeting, regardless | ||
* of the input value(s) you provide. | ||
* | ||
* @param {string} type - force a specific data type. the type choices | ||
* are: 'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (default: the | ||
* smallest one that fits the `value`) | ||
* @param {number|bigint|string|XdrLargeInt|ScInt|Array<number|bigint|string|XdrLargeInt|ScInt>} values | ||
* - a list of integer-like values interpreted in big-endian order | ||
*/ | ||
var XdrLargeInt = /*#__PURE__*/function () { | ||
@@ -24,0 +37,0 @@ function XdrLargeInt(type, values) { |
@@ -10,7 +10,10 @@ "use strict"; | ||
/** | ||
* Builds a footprint restoration operation. It takes no parameters because the | ||
* relevant footprint is derived from the transaction itself (see | ||
* {@link TransactionBuilder}'s `opts.sorobanData` parameter, which is a | ||
* Builds a footprint restoration operation. | ||
* | ||
* It takes no parameters because the relevant footprint is derived from the | ||
* transaction itself (see {@link TransactionBuilder}'s `opts.sorobanData` | ||
* parameter (or {@link TransactionBuilder.setSorobanData} / | ||
* {@link TransactionBuilder.setLedgerKeys}), which is a | ||
* {@link xdr.SorobanTransactionData} instance that contains fee data & resource | ||
* usage as part of {@link xdr.SorobanResources}). | ||
* usage as part of {@link xdr.SorobanTransactionData}). | ||
* | ||
@@ -17,0 +20,0 @@ * @function |
@@ -19,39 +19,3 @@ "use strict"; | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } /** | ||
* Provides conversions from smart contract XDR values ({@link xdr.ScVal}) to | ||
* native JavaScript types. | ||
* | ||
* @example | ||
* ```js | ||
* import { nativeToScVal, scValToNative, ScInt, xdr } from 'stellar-base'; | ||
* | ||
* let gigaMap = { | ||
* bool: true, | ||
* void: null, | ||
* u32: xdr.ScVal.scvU32(1), | ||
* i32: xdr.ScVal.scvI32(1), | ||
* u64: 1n, | ||
* i64: -1n, | ||
* u128: new ScInt(1).toU128(), | ||
* i128: new ScInt(1).toI128(), | ||
* u256: new ScInt(1).toU256(), | ||
* i256: new ScInt(1).toI256(), | ||
* map: { | ||
* arbitrary: 1n, | ||
* nested: 'values', | ||
* etc: false | ||
* }, | ||
* vec: ['same', 'type', 'list'], | ||
* }; | ||
* | ||
* // then, simply: | ||
* let scv = nativeToScVal(gigaMap); // scv.switch() == xdr.ScValType.scvMap() | ||
* | ||
* // then... | ||
* someContract.call("method", scv); | ||
* | ||
* // Similarly, the inverse should work: | ||
* scValToNative(scv) == gigaMap; // true | ||
* ``` | ||
*/ | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
/** | ||
@@ -61,2 +25,5 @@ * Attempts to convert native types into smart contract values | ||
* | ||
* Provides conversions from smart contract XDR values ({@link xdr.ScVal}) to | ||
* native JavaScript types. | ||
* | ||
* The conversions are as follows: | ||
@@ -128,4 +95,2 @@ * | ||
* @example | ||
* | ||
* ```js | ||
* nativeToScVal(1000); // gives ScValType === scvU64 | ||
@@ -153,3 +118,35 @@ * nativeToScVal(1000n); // gives ScValType === scvU64 | ||
* // ] | ||
* ``` | ||
* | ||
* @example | ||
* import { nativeToScVal, scValToNative, ScInt, xdr } from 'stellar-base'; | ||
* | ||
* let gigaMap = { | ||
* bool: true, | ||
* void: null, | ||
* u32: xdr.ScVal.scvU32(1), | ||
* i32: xdr.ScVal.scvI32(1), | ||
* u64: 1n, | ||
* i64: -1n, | ||
* u128: new ScInt(1).toU128(), | ||
* i128: new ScInt(1).toI128(), | ||
* u256: new ScInt(1).toU256(), | ||
* i256: new ScInt(1).toI256(), | ||
* map: { | ||
* arbitrary: 1n, | ||
* nested: 'values', | ||
* etc: false | ||
* }, | ||
* vec: ['same', 'type', 'list'], | ||
* }; | ||
* | ||
* // then, simply: | ||
* let scv = nativeToScVal(gigaMap); // scv.switch() == xdr.ScValType.scvMap() | ||
* | ||
* // then... | ||
* someContract.call("method", scv); | ||
* | ||
* // Similarly, the inverse should work: | ||
* scValToNative(scv) == gigaMap; // true | ||
* | ||
* @see scValToNative | ||
*/ | ||
@@ -282,2 +279,3 @@ function nativeToScVal(val) { | ||
* @returns {any} | ||
* @see nativeToScVal | ||
*/ | ||
@@ -284,0 +282,0 @@ function scValToNative(scv) { |
@@ -11,7 +11,11 @@ "use strict"; | ||
var _xdr = _interopRequireDefault(require("./xdr")); | ||
var _account = require("./account"); | ||
var _muxed_account = require("./muxed_account"); | ||
var _decode_encode_muxed_account = require("./util/decode_encode_muxed_account"); | ||
var _transaction = require("./transaction"); | ||
var _fee_bump_transaction = require("./fee_bump_transaction"); | ||
var _sorobandata_builder = require("./sorobandata_builder"); | ||
var _strkey = require("./strkey"); | ||
var _signerkey = require("./signerkey"); | ||
var _memo = require("./memo"); | ||
var _decode_encode_muxed_account = require("./util/decode_encode_muxed_account"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -132,7 +136,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
* 2015" for the pubnet) | ||
* @param {xdr.SorobanTransactionData | string} [opts.sorobanData] - an optional xdr instance of SorobanTransactionData | ||
* to be set as .Transaction.Ext.SorobanData. It can be xdr object or base64 string. | ||
* For non-contract(non-Soroban) transactions, this has no effect. | ||
* In the case of Soroban transactions, SorobanTransactionData can be obtained from a prior simulation of | ||
* the transaction with a contract invocation and provides necessary resource estimations. | ||
* @param {xdr.SorobanTransactionData | string} [opts.sorobanData] - an | ||
* optional instance of {@link xdr.SorobanTransactionData} to be set as the | ||
* internal `Transaction.Ext.SorobanData` field (either the xdr object or a | ||
* base64 string). In the case of Soroban transactions, this can be obtained | ||
* from a prior simulation of the transaction with a contract invocation and | ||
* provides necessary resource estimations. You can also use | ||
* {@link SorobanDataBuilder} to construct complicated combinations of | ||
* parameters without mucking with XDR directly. **Note:** For | ||
* non-contract(non-Soroban) transactions, this has no effect. | ||
* | ||
@@ -162,16 +170,37 @@ */ | ||
this.networkPassphrase = opts.networkPassphrase || null; | ||
this.sorobanData = unmarshalSorobanData(opts.sorobanData); | ||
this.sorobanData = opts.sorobanData ? new _sorobandata_builder.SorobanDataBuilder(opts.sorobanData).build() : null; | ||
} | ||
/** | ||
* Adds an operation to the transaction. | ||
* Creates a builder instance using an existing {@link Transaction} as a | ||
* template, ignoring any existing envelope signatures. | ||
* | ||
* @param {xdr.Operation} operation The xdr operation object, use {@link | ||
* Operation} static methods. | ||
* Note that the sequence number WILL be cloned, so EITHER this transaction or | ||
* the one it was cloned from will be valid. This is useful in situations | ||
* where you are constructing a transaction in pieces and need to make | ||
* adjustments as you go (for example, when filling out Soroban resource | ||
* information). | ||
* | ||
* @returns {TransactionBuilder} | ||
* @param {Transaction} tx a "template" transaction to clone exactly | ||
* @param {object} [opts] additional options to override the clone, e.g. | ||
* {fee: '1000'} will override the existing base fee derived from `tx` (see | ||
* the {@link TransactionBuilder} constructor for detailed options) | ||
* | ||
* @returns {TransactionBuilder} a "prepared" builder instance with the same | ||
* configuration and operations as the given transaction | ||
* | ||
* @todo This cannot clone {@link FeeBumpTransaction}s, yet. | ||
*/ | ||
_createClass(TransactionBuilder, [{ | ||
key: "addOperation", | ||
value: function addOperation(operation) { | ||
value: | ||
/** | ||
* Adds an operation to the transaction. | ||
* | ||
* @param {xdr.Operation} operation The xdr operation object, use {@link | ||
* Operation} static methods. | ||
* | ||
* @returns {TransactionBuilder} | ||
*/ | ||
function addOperation(operation) { | ||
this.operations.push(operation); | ||
@@ -464,13 +493,15 @@ return this; | ||
/** | ||
* Set the {SorobanTransactionData}. For non-contract(non-Soroban) transactions, | ||
* this setting has no effect. | ||
* In the case of Soroban transactions, set to an instance of | ||
* SorobanTransactionData. This can typically be obtained from the simulation | ||
* response based on a transaction with a InvokeHostFunctionOp. | ||
* It provides necessary resource estimations for contract invocation. | ||
* Set the {SorobanTransactionData}. For non-contract(non-Soroban) | ||
* transactions, this setting has no effect. In the case of Soroban | ||
* transactions, set to an instance of SorobanTransactionData. This can | ||
* typically be obtained from the simulation response based on a transaction | ||
* with a InvokeHostFunctionOp. It provides necessary resource estimations for | ||
* contract invocation. | ||
* | ||
* @param {xdr.SorobanTransactionData | string} sorobanData the SorobanTransactionData as xdr object or base64 string | ||
* to be set as Transaction.Ext.SorobanData. | ||
* @param {xdr.SorobanTransactionData | string} sorobanData the | ||
* {@link xdr.SorobanTransactionData} as a raw xdr object or a base64 | ||
* string to be decoded then set as Transaction.Ext.SorobanData | ||
* | ||
* @returns {TransactionBuilder} | ||
* @see {SorobanDataBuilder} | ||
*/ | ||
@@ -480,3 +511,3 @@ }, { | ||
value: function setSorobanData(sorobanData) { | ||
this.sorobanData = unmarshalSorobanData(sorobanData); | ||
this.sorobanData = new _sorobandata_builder.SorobanDataBuilder(sorobanData).build(); | ||
return this; | ||
@@ -585,2 +616,39 @@ } | ||
}], [{ | ||
key: "cloneFrom", | ||
value: function cloneFrom(tx) { | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (!(tx instanceof _transaction.Transaction)) { | ||
throw new TypeError("expected a 'Transaction', got: ".concat(tx)); | ||
} | ||
var sequenceNum = "".concat(parseInt(tx.sequence, 10) - 1); | ||
var source; | ||
// rebuild the source account based on the strkey | ||
if (_strkey.StrKey.isValidMed25519PublicKey(tx.source)) { | ||
source = _muxed_account.MuxedAccount.fromAddress(tx.source, sequenceNum); | ||
} else if (_strkey.StrKey.isValidEd25519PublicKey(tx.source)) { | ||
source = new _account.Account(tx.source, sequenceNum); | ||
} else { | ||
throw new TypeError("unsupported tx source account: ".concat(tx.source)); | ||
} | ||
// the initial fee passed to the builder gets scaled up based on the number | ||
// of operations at the end, so we have to down-scale first | ||
var unscaledFee = parseInt(tx.fee, 10) / tx.operations.length; | ||
var builder = new TransactionBuilder(source, _objectSpread({ | ||
fee: (unscaledFee || BASE_FEE).toString(), | ||
memo: tx.memo, | ||
networkPassphrase: tx.networkPassphrase, | ||
timebounds: tx.timeBounds, | ||
ledgerbounds: tx.ledgerBounds, | ||
minAccountSequence: tx.minAccountSequence, | ||
minAccountSequenceAge: tx.minAccountSequenceAge, | ||
minAccountSequenceLedgerGap: tx.minAccountSequenceLedgerGap, | ||
extraSigners: tx.extraSigners | ||
}, opts)); | ||
tx._tx.operations().forEach(function (op) { | ||
return builder.addOperation(op); | ||
}); | ||
return builder; | ||
} | ||
}, { | ||
key: "buildFeeBumpTransaction", | ||
@@ -675,16 +743,2 @@ value: function buildFeeBumpTransaction(feeSource, baseFee, innerTx, networkPassphrase) { | ||
return d instanceof Date && !isNaN(d); | ||
} | ||
/** | ||
* local helper function to convert SorobanTransactionData from | ||
* base64 string or xdr object. | ||
* @param {string | xdr.SorobanTransactionData} sorobanData the soroban transaction data | ||
* @returns {xdr.SorobanTransactionData} | ||
*/ | ||
function unmarshalSorobanData(sorobanData) { | ||
if (typeof sorobanData === 'string') { | ||
var buffer = Buffer.from(sorobanData, 'base64'); | ||
sorobanData = _xdr["default"].SorobanTransactionData.fromXDR(buffer); | ||
} | ||
return sorobanData; | ||
} |
{ | ||
"name": "stellar-base", | ||
"version": "10.0.0-soroban.4", | ||
"version": "10.0.0-soroban.5", | ||
"description": "Low-level support library for the Stellar network.", | ||
@@ -79,6 +79,6 @@ "main": "./lib/index.js", | ||
"@babel/register": "^7.21.0", | ||
"@definitelytyped/dtslint": "^0.0.163", | ||
"@definitelytyped/dtslint": "^0.0.165", | ||
"@istanbuljs/nyc-config-babel": "3.0.0", | ||
"@types/node": "^20.4.2", | ||
"@typescript-eslint/parser": "^5.61.0", | ||
"@types/node": "^20.4.7", | ||
"@typescript-eslint/parser": "^6.2.1", | ||
"babel-loader": "^9.1.3", | ||
@@ -90,7 +90,7 @@ "babel-plugin-istanbul": "^6.1.1", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-config-prettier": "^8.10.0", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prefer-import": "^0.0.1", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"eslint-webpack-plugin": "^4.0.0", | ||
@@ -112,3 +112,3 @@ "ghooks": "^2.0.4", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.8.8", | ||
"prettier": "^3.0.1", | ||
"randombytes": "^2.1.0", | ||
@@ -128,4 +128,2 @@ "sinon": "^15.0.3", | ||
"buffer": "^6.0.3", | ||
"crc": "^4.3.2", | ||
"crypto-browserify": "^3.12.0", | ||
"js-xdr": "^3.0.0", | ||
@@ -132,0 +130,0 @@ "sha.js": "^2.3.6", |
@@ -101,5 +101,5 @@ # JS Stellar Base | ||
1. Install Node 14.x | ||
1. Install Node 16.x | ||
We support the oldest LTS release of Node, which is [currently 14.x](https://nodejs.org/en/about/releases/). Please likewise install and develop on Node 14 so you don't get surprised when your code works locally but breaks in CI. | ||
We support the oldest LTS release of Node, which is [currently 16.x](https://nodejs.org/en/about/releases/). Please likewise install and develop on Node 16 so you don't get surprised when your code works locally but breaks in CI. | ||
@@ -106,0 +106,0 @@ If you work on several projects that use different Node versions, you might find helpful to install a NodeJS version manager: |
@@ -30,3 +30,3 @@ // TypeScript Version: 2.9 | ||
constructor(contractId: string); | ||
contractId(format?: 'hex' | 'strkey'): string; | ||
contractId(): string; | ||
address(): Address; | ||
@@ -1032,2 +1032,4 @@ call(method: string, ...params: xdr.ScVal[]): xdr.Operation<Operation.InvokeHostFunction>; | ||
setNetworkPassphrase(networkPassphrase: string): this; | ||
static cloneFrom(tx: Transaction): TransactionBuilder; | ||
static buildFeeBumpTransaction( | ||
@@ -1088,6 +1090,8 @@ feeSource: Keypair | string, | ||
export type IntLike = string | number | bigint; | ||
export class XdrLargeInt { | ||
constructor( | ||
type: ScIntType, | ||
values: number|bigint|string|Array<number|bigint|string> | ||
values: IntLike | IntLike[] | ||
); | ||
@@ -1114,3 +1118,3 @@ | ||
export class ScInt extends XdrLargeInt { | ||
constructor(value: number|bigint|string|ScInt, opts?: { type: ScIntType }); | ||
constructor(value: IntLike | ScInt, opts?: { type: ScIntType }); | ||
} | ||
@@ -1121,1 +1125,62 @@ | ||
export function scValToNative(scv: xdr.ScVal): any; | ||
interface SorobanEvent { | ||
type: 'system'|'contract'|'diagnostic'; // xdr.ContractEventType.name | ||
contractId?: string; // C... encoded strkey | ||
topics: any[]; // essentially a call of map(event.body.topics, scValToNative) | ||
data: any; // similarly, scValToNative(rawEvent.data); | ||
} | ||
export function humanizeEvents( | ||
events: xdr.DiagnosticEvent[] | xdr.ContractEvent[] | ||
): SorobanEvent[]; | ||
export class SorobanDataBuilder { | ||
constructor(data?: string | xdr.SorobanTransactionData); | ||
setRefundableFee(fee: IntLike): SorobanDataBuilder; | ||
setResources( | ||
cpuInstrs: number, | ||
readBytes: number, | ||
writeBytes: number, | ||
metadataBytes: number | ||
): SorobanDataBuilder; | ||
setFootprint( | ||
readOnly?: xdr.LedgerKey[] | null, | ||
readWrite?: xdr.LedgerKey[] | null | ||
): SorobanDataBuilder; | ||
setReadOnly(keys?: xdr.LedgerKey[]): SorobanDataBuilder; | ||
setReadWrite(keys?: xdr.LedgerKey[]): SorobanDataBuilder; | ||
build(): xdr.SorobanTransactionData; | ||
} | ||
export function authorizeInvocation( | ||
signer: Keypair, | ||
networkPassphrase: string, | ||
validUntil: number, | ||
invocation: xdr.SorobanAuthorizedInvocation | ||
): xdr.SorobanAuthorizationEntry; | ||
export function authorizeInvocationCallback( | ||
publicKey: string, | ||
signingMethod: (input: Buffer) => Buffer, | ||
networkPassphrase: string, | ||
validUntil: number, | ||
invocation: xdr.SorobanAuthorizedInvocation | ||
): xdr.SorobanAuthorizationEntry; | ||
export function buildAuthEnvelope( | ||
networkPassphrase: string, | ||
validUntil: number, | ||
invocation: xdr.SorobanAuthorizedInvocation | ||
): xdr.HashIdPreimage; | ||
export function buildAuthEntry( | ||
envelope: xdr.HashIdPreimage, | ||
signature: Buffer | Uint8Array, | ||
publicKey: string | ||
): xdr.SorobanAuthorizationEntry; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
3227687
7
78
65264
- Removedcrc@^4.3.2
- Removedcrypto-browserify@^3.12.0
- Removedasn1.js@4.10.1(transitive)
- Removedbn.js@4.12.15.2.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedbrowserify-aes@1.2.0(transitive)
- Removedbrowserify-cipher@1.0.1(transitive)
- Removedbrowserify-des@1.0.2(transitive)
- Removedbrowserify-rsa@4.1.1(transitive)
- Removedbrowserify-sign@4.2.3(transitive)
- Removedbuffer-xor@1.0.3(transitive)
- Removedcipher-base@1.0.6(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcrc@4.3.2(transitive)
- Removedcreate-ecdh@4.0.4(transitive)
- Removedcreate-hash@1.2.0(transitive)
- Removedcreate-hmac@1.1.7(transitive)
- Removedcrypto-browserify@3.12.1(transitive)
- Removeddes.js@1.1.0(transitive)
- Removeddiffie-hellman@5.0.3(transitive)
- Removedelliptic@6.6.1(transitive)
- Removedevp_bytestokey@1.0.3(transitive)
- Removedhash-base@3.0.5(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedisarray@1.0.0(transitive)
- Removedmd5.js@1.3.5(transitive)
- Removedmiller-rabin@4.0.1(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removedparse-asn1@5.1.7(transitive)
- Removedpbkdf2@3.1.2(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedpublic-encrypt@4.0.3(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedrandomfill@1.0.4(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedripemd160@2.0.2(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)