Comparing version 0.0.23 to 0.0.24
@@ -123,2 +123,83 @@ const sui = require('@mysten/sui.js'); | ||
get version() { | ||
return this._version; | ||
} | ||
/** | ||
* Try to get past version of an object from blockchain. | ||
* Non-cacheable | ||
* Note from SUI docs, there's no garantee past version is available on nodes, so may return null even if you expect v to be there | ||
* @param {Number} v | ||
* @returns SuiObject | ||
*/ | ||
async getPastObject(v = null) { | ||
if (!v) { | ||
v = this._version - BigInt(1); | ||
} | ||
v = Number(v); | ||
const result = await this._suiMaster._provider.tryGetPastObject({ | ||
version: (v), | ||
id: this.address, | ||
options: { | ||
showType: true, | ||
showContent: true, | ||
showOwner: true, | ||
showDisplay: true, | ||
"showPreviousTransaction": true, | ||
"showBcs": false, | ||
"showStorageRebate": true | ||
}, | ||
}); | ||
if (result && result.details && result.details.objectId) { | ||
const pastObject = new SuiObject({ | ||
suiMaster: this._suiMaster, | ||
debug: this._debug, | ||
objectChange: result.details, | ||
}); | ||
return pastObject; | ||
} | ||
return null; | ||
} | ||
async queryTransactionBlocks(params = {}) { | ||
// @todo: InputObject / ChangedObject ? make separate function or a param here? | ||
const queryParams = { | ||
filter: { | ||
InputObject: this.address, | ||
}, | ||
limit: params.limit || 10, | ||
options: { | ||
/* Whether to show transaction input data. Default to be false. */ | ||
showInput: true, | ||
/* Whether to show transaction effects. Default to be false. */ | ||
showEffects: true, | ||
/* Whether to show transaction events. Default to be false. */ | ||
showEvents: true, | ||
/* Whether to show object changes. Default to be false. */ | ||
showObjectChanges: true, | ||
/* Whether to show coin balance changes. Default to be false. */ | ||
showBalanceChanges: true, | ||
showContent: true, | ||
showOwner: true, | ||
showDisplay: true, | ||
}, | ||
}; | ||
const paginatedResponse = new SuiPaginatedResponse({ | ||
debug: this._debug, | ||
suiMaster: this._suiMaster, | ||
params: queryParams, | ||
method: 'queryTransactionBlocks', | ||
order: params.order, | ||
}); | ||
await paginatedResponse.fetch(); | ||
return paginatedResponse; | ||
} | ||
async getDynamicFields(params = {}) { | ||
@@ -125,0 +206,0 @@ const queryParams = { |
{ | ||
"name": "suidouble", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Set of provider, package and object classes for javascript representation of Sui Move smart contracts. Use same code for publishing, upgrading, integration testing, interaction with smart contracts and integration in browser web3 dapps", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -127,2 +127,7 @@ # suidouble | ||
suiObject.isOwnedBy('0x10cded4f9df05e37b44e3be2ffa9004dec77786950719fad6083694fdca45bf2'); // is object owned by somebody or some object | ||
/// past versions: | ||
await suiObject.getPastObject(version); // get instance of object from the past | ||
await suiObject.getPastObject(); // try to get previous | ||
/// object-related transactions: | ||
await suiObject.queryTransactionBlocks(); // returns instance of SuiPaginatedResponse | ||
``` | ||
@@ -129,0 +134,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182648
2625
363