@keetanetwork/keetanet-client 0.14.2 → 0.14.3
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 +4 -0
- package/api/node.d.ts +1 -0
- package/client/index-browser.d.ts +5 -0
- package/client/index-browser.js +56 -16
- package/client/index.d.ts +5 -0
- package/client/index.js +32 -1
- package/docs/GETTING-STARTED.md +361 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperation.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationRECEIVE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSEND.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_INFO.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationSET_REP.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BlockOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.CertificateHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSAKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256K1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ECDSASECP256R1Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519KeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PrivateKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519PublicKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ED25519Signature.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.ExternalSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKey.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.IdentifierKeyPair.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetError.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeyStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Ledger.html +3 -2
- package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +2 -1
- package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.SignatureStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Stats.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.StatsPending.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteLikeBase.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteQuoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStaple.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
- package/docs/documents/GETTING-STARTED.html +3 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +2 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ExplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1ImplicitContextTag.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ASN1Object.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseExternalKeyPairFunctions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseGenerationConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperation.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationCREATE_IDENTIFIER.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMANAGE_CERTIFICATESerializable.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationMODIFY_PERMISSIONS.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationRECEIVE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSEND.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_INFO.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationSET_REP.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockJSONOperationTOKEN_ADMIN_SUPPLY.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV1Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.BlockV2Canonical.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsNoEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ExternalKeyPairFunctionsSupportsEncryption.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InitialConfigSupply.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.InstanceSet.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVGenericOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.KVSetOptionsType.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.LedgerStorageAPI.html +5 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.NumericValueEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerListener.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.P2PPeerRepBase.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.TokenNumericEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.UserClientConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.UserClientOptions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1BitString.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Date.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1OID.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Set.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1String.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseFormatted.html +5 -2
- package/docs/types/KeetaNetSDK.Referenced.GetAccountStateAPIResponseSuccess.html +3 -2
- package/lib/ledger/common.d.ts +9 -0
- package/lib/ledger/index.d.ts +23 -0
- package/lib/p2p.d.ts +1 -1
- package/package.json +1 -1
- package/version.d.ts +1 -1
package/README.md
CHANGED
|
@@ -5,3 +5,7 @@ This package implements KeetaNet Client SDK in JavaScript
|
|
|
5
5
|
|
|
6
6
|
See the [Getting Started](docs/GETTING-STARTED.md) Guide for more
|
|
7
7
|
information on first steps with the KeetaNet SDK.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
See the full documentation for the KeetaNet Client JavaScript/TypeScript SDK at [https://static.test.keeta.com/docs/](https://static.test.keeta.com/docs/).
|
package/api/node.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface GetAccountChainAPIResponse {
|
|
|
28
28
|
interface AccountState {
|
|
29
29
|
account: GenericAccount;
|
|
30
30
|
currentHeadBlock: BlockHash | null;
|
|
31
|
+
currentHeadBlockHeight: bigint | null;
|
|
31
32
|
representative: Account | null;
|
|
32
33
|
balances: GetAllBalancesResponse;
|
|
33
34
|
info: AccountInfo;
|
|
@@ -42,6 +42,11 @@ type GetAccountStateAPIResponseFormatted = {
|
|
|
42
42
|
* this will be null if the account is not open
|
|
43
43
|
*/
|
|
44
44
|
currentHeadBlock: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The current height of the head block for the account, if there is one
|
|
47
|
+
* this will be null if the account is not open
|
|
48
|
+
*/
|
|
49
|
+
currentHeadBlockHeight: string | null;
|
|
45
50
|
/**
|
|
46
51
|
* The current representative for the account, if there is one
|
|
47
52
|
* this will be null if the account is not open or if the
|
package/client/index-browser.js
CHANGED
|
@@ -117272,10 +117272,36 @@ class client_LedgerStorageBase {
|
|
|
117272
117272
|
}));
|
|
117273
117273
|
return Object.fromEntries(response);
|
|
117274
117274
|
}
|
|
117275
|
+
async getAccountsBlockHeightInfo(transaction, toFetch) {
|
|
117276
|
+
const response = await Promise.all(toFetch.map(async _ref2 => {
|
|
117277
|
+
let {
|
|
117278
|
+
blockHash,
|
|
117279
|
+
account
|
|
117280
|
+
} = _ref2;
|
|
117281
|
+
if (blockHash === undefined) {
|
|
117282
|
+
const block = await this.getHeadBlock(transaction, account, 'main');
|
|
117283
|
+
if (block !== null) {
|
|
117284
|
+
blockHash = block.hash;
|
|
117285
|
+
}
|
|
117286
|
+
}
|
|
117287
|
+
const retval = [];
|
|
117288
|
+
if (blockHash === undefined) {
|
|
117289
|
+
retval.push(...[account.publicKeyString.get(), null]);
|
|
117290
|
+
} else {
|
|
117291
|
+
const height = await this.getBlockHeight(transaction, blockHash, account);
|
|
117292
|
+
retval.push(...[account.publicKeyString.get(), {
|
|
117293
|
+
blockHash,
|
|
117294
|
+
height
|
|
117295
|
+
}]);
|
|
117296
|
+
}
|
|
117297
|
+
return retval;
|
|
117298
|
+
}));
|
|
117299
|
+
return Object.fromEntries(response);
|
|
117300
|
+
}
|
|
117275
117301
|
async getHeadBlockHashes(transaction, accounts) {
|
|
117276
117302
|
const received = await this.getHeadBlocks(transaction, accounts.toArray(), 'both');
|
|
117277
|
-
return Object.fromEntries(Object.entries(received).map(function (
|
|
117278
|
-
let [account, value] =
|
|
117303
|
+
return Object.fromEntries(Object.entries(received).map(function (_ref3) {
|
|
117304
|
+
let [account, value] = _ref3;
|
|
117279
117305
|
if (value) {
|
|
117280
117306
|
return [account, value.hash];
|
|
117281
117307
|
} else {
|
|
@@ -125948,6 +125974,11 @@ class client_LedgerAtomicInterface {
|
|
|
125948
125974
|
const retval = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getBlock(transaction, blockhash, from);
|
|
125949
125975
|
return retval;
|
|
125950
125976
|
}
|
|
125977
|
+
async getAccountsBlockHeightInfo(toFetch) {
|
|
125978
|
+
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
125979
|
+
const retval = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getAccountsBlockHeightInfo(transaction, toFetch);
|
|
125980
|
+
return retval;
|
|
125981
|
+
}
|
|
125951
125982
|
async getVoteStaple(stapleBlockHash) {
|
|
125952
125983
|
let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'main';
|
|
125953
125984
|
client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
@@ -126853,57 +126884,65 @@ class src_client_Ledger {
|
|
|
126853
126884
|
return await transaction.getBlock(...args);
|
|
126854
126885
|
});
|
|
126855
126886
|
}
|
|
126856
|
-
async
|
|
126887
|
+
async getAccountsBlockHeightInfo() {
|
|
126857
126888
|
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
|
126858
126889
|
args[_key19] = arguments[_key19];
|
|
126859
126890
|
}
|
|
126891
|
+
return await this.runReadOnly('db-getAccountsBlockHeightInfo', async function (transaction) {
|
|
126892
|
+
return await transaction.getAccountsBlockHeightInfo(...args);
|
|
126893
|
+
});
|
|
126894
|
+
}
|
|
126895
|
+
async getVoteStaple() {
|
|
126896
|
+
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
|
126897
|
+
args[_key20] = arguments[_key20];
|
|
126898
|
+
}
|
|
126860
126899
|
return await this.runReadOnly('db-getVoteStaple', async function (transaction) {
|
|
126861
126900
|
return await transaction.getVoteStaple(...args);
|
|
126862
126901
|
});
|
|
126863
126902
|
}
|
|
126864
126903
|
async getVoteStaples() {
|
|
126865
|
-
for (var
|
|
126866
|
-
args[
|
|
126904
|
+
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
|
126905
|
+
args[_key21] = arguments[_key21];
|
|
126867
126906
|
}
|
|
126868
126907
|
return await this.runReadOnly('db-getVoteStaples', async function (transaction) {
|
|
126869
126908
|
return await transaction.getVoteStaples(...args);
|
|
126870
126909
|
});
|
|
126871
126910
|
}
|
|
126872
126911
|
async getHistory() {
|
|
126873
|
-
for (var
|
|
126874
|
-
args[
|
|
126912
|
+
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
|
126913
|
+
args[_key22] = arguments[_key22];
|
|
126875
126914
|
}
|
|
126876
126915
|
return await this.runReadOnly('db-getHistory', async function (transaction) {
|
|
126877
126916
|
return await transaction.getHistory(...args);
|
|
126878
126917
|
});
|
|
126879
126918
|
}
|
|
126880
126919
|
async getStaplesFromBlockHashes() {
|
|
126881
|
-
for (var
|
|
126882
|
-
args[
|
|
126920
|
+
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
|
126921
|
+
args[_key23] = arguments[_key23];
|
|
126883
126922
|
}
|
|
126884
126923
|
return await this.runReadOnly('db-getStaplesFromBlockHashes', async function (transaction) {
|
|
126885
126924
|
return await transaction.getStaplesFromBlockHashes(...args);
|
|
126886
126925
|
});
|
|
126887
126926
|
}
|
|
126888
126927
|
async getVoteStaplesAfter() {
|
|
126889
|
-
for (var
|
|
126890
|
-
args[
|
|
126928
|
+
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
|
|
126929
|
+
args[_key24] = arguments[_key24];
|
|
126891
126930
|
}
|
|
126892
126931
|
return await this.runReadOnly('db-getVoteStaplesAfter', async function (transaction) {
|
|
126893
126932
|
return await transaction.getVoteStaplesAfter(...args);
|
|
126894
126933
|
});
|
|
126895
126934
|
}
|
|
126896
126935
|
async gc() {
|
|
126897
|
-
for (var
|
|
126898
|
-
args[
|
|
126936
|
+
for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
|
|
126937
|
+
args[_key25] = arguments[_key25];
|
|
126899
126938
|
}
|
|
126900
126939
|
return await this.run('db-gc', async function (transaction) {
|
|
126901
126940
|
return await transaction.gc(...args);
|
|
126902
126941
|
});
|
|
126903
126942
|
}
|
|
126904
126943
|
async getFee() {
|
|
126905
|
-
for (var
|
|
126906
|
-
args[
|
|
126944
|
+
for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
|
|
126945
|
+
args[_key26] = arguments[_key26];
|
|
126907
126946
|
}
|
|
126908
126947
|
return await this.runReadOnly('db-getFee', async function (transaction) {
|
|
126909
126948
|
return await transaction.getFee(...args);
|
|
@@ -126935,7 +126974,7 @@ client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkab
|
|
|
126935
126974
|
// EXTERNAL MODULE: ws (ignored)
|
|
126936
126975
|
var client_ws_ignored_ = __webpack_require__(4708);
|
|
126937
126976
|
;// ./src/version.ts
|
|
126938
|
-
const client_version = '0.14.
|
|
126977
|
+
const client_version = '0.14.3+gc0f4c96265aa999e6f32e3b21443d294bbf33806';
|
|
126939
126978
|
/* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
|
|
126940
126979
|
;// ./src/lib/p2p.ts
|
|
126941
126980
|
/* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];
|
|
@@ -132076,6 +132115,7 @@ function client_parseAccountInfo(account, accountInfo) {
|
|
|
132076
132115
|
return {
|
|
132077
132116
|
account: client_src_lib.Account.fromPublicKeyString(accountInfo.account),
|
|
132078
132117
|
currentHeadBlock: currentHeadBlock,
|
|
132118
|
+
currentHeadBlockHeight: accountInfo.currentHeadBlockHeight,
|
|
132079
132119
|
representative: currentRepresentative,
|
|
132080
132120
|
info: client_client_assertClassBrand(client_Client_brand, this, client_formatAccountInfo).call(this, accountInfo.info),
|
|
132081
132121
|
balances: client_client_assertClassBrand(client_Client_brand, this, client_formatAllBalances).call(this, accountInfo.balances)
|
package/client/index.d.ts
CHANGED
|
@@ -42,6 +42,11 @@ type GetAccountStateAPIResponseFormatted = {
|
|
|
42
42
|
* this will be null if the account is not open
|
|
43
43
|
*/
|
|
44
44
|
currentHeadBlock: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The current height of the head block for the account, if there is one
|
|
47
|
+
* this will be null if the account is not open
|
|
48
|
+
*/
|
|
49
|
+
currentHeadBlockHeight: string | null;
|
|
45
50
|
/**
|
|
46
51
|
* The current representative for the account, if there is one
|
|
47
52
|
* this will be null if the account is not open or if the
|
package/client/index.js
CHANGED
|
@@ -59579,6 +59579,7 @@ async function _Client_apiRaw(rep, api, method, options = {}) {
|
|
|
59579
59579
|
return ({
|
|
59580
59580
|
account: lib_1.default.Account.fromPublicKeyString(accountInfo.account),
|
|
59581
59581
|
currentHeadBlock: currentHeadBlock,
|
|
59582
|
+
currentHeadBlockHeight: accountInfo.currentHeadBlockHeight,
|
|
59582
59583
|
representative: currentRepresentative,
|
|
59583
59584
|
info: __classPrivateFieldGet(this, _Client_instances, "m", _Client_formatAccountInfo).call(this, accountInfo.info),
|
|
59584
59585
|
balances: __classPrivateFieldGet(this, _Client_instances, "m", _Client_formatAllBalances).call(this, accountInfo.balances)
|
|
@@ -66097,6 +66098,26 @@ class LedgerStorageBase {
|
|
|
66097
66098
|
}));
|
|
66098
66099
|
return (Object.fromEntries(response));
|
|
66099
66100
|
}
|
|
66101
|
+
async getAccountsBlockHeightInfo(transaction, toFetch) {
|
|
66102
|
+
const response = await Promise.all(toFetch.map(async ({ blockHash, account }) => {
|
|
66103
|
+
if (blockHash === undefined) {
|
|
66104
|
+
const block = await this.getHeadBlock(transaction, account, 'main');
|
|
66105
|
+
if (block !== null) {
|
|
66106
|
+
blockHash = block.hash;
|
|
66107
|
+
}
|
|
66108
|
+
}
|
|
66109
|
+
const retval = [];
|
|
66110
|
+
if (blockHash === undefined) {
|
|
66111
|
+
retval.push(...[account.publicKeyString.get(), null]);
|
|
66112
|
+
}
|
|
66113
|
+
else {
|
|
66114
|
+
const height = await this.getBlockHeight(transaction, blockHash, account);
|
|
66115
|
+
retval.push(...[account.publicKeyString.get(), { blockHash, height }]);
|
|
66116
|
+
}
|
|
66117
|
+
return (retval);
|
|
66118
|
+
}));
|
|
66119
|
+
return (Object.fromEntries(response));
|
|
66120
|
+
}
|
|
66100
66121
|
async getHeadBlockHashes(transaction, accounts) {
|
|
66101
66122
|
const received = await this.getHeadBlocks(transaction, accounts.toArray(), 'both');
|
|
66102
66123
|
return (Object.fromEntries(Object.entries(received).map(function ([account, value]) {
|
|
@@ -67596,6 +67617,11 @@ class LedgerAtomicInterface {
|
|
|
67596
67617
|
const retval = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").getBlock(transaction, blockhash, from);
|
|
67597
67618
|
return (retval);
|
|
67598
67619
|
}
|
|
67620
|
+
async getAccountsBlockHeightInfo(toFetch) {
|
|
67621
|
+
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
67622
|
+
const retval = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").getAccountsBlockHeightInfo(transaction, toFetch);
|
|
67623
|
+
return (retval);
|
|
67624
|
+
}
|
|
67599
67625
|
async getVoteStaple(stapleBlockHash, from = 'main') {
|
|
67600
67626
|
__classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
67601
67627
|
const results = await this.getVoteStaples([stapleBlockHash], from);
|
|
@@ -68365,6 +68391,11 @@ class Ledger {
|
|
|
68365
68391
|
return (await transaction.getBlock(...args));
|
|
68366
68392
|
}));
|
|
68367
68393
|
}
|
|
68394
|
+
async getAccountsBlockHeightInfo(...args) {
|
|
68395
|
+
return (await this.runReadOnly('db-getAccountsBlockHeightInfo', async function (transaction) {
|
|
68396
|
+
return (await transaction.getAccountsBlockHeightInfo(...args));
|
|
68397
|
+
}));
|
|
68398
|
+
}
|
|
68368
68399
|
async getVoteStaple(...args) {
|
|
68369
68400
|
return (await this.runReadOnly('db-getVoteStaple', async function (transaction) {
|
|
68370
68401
|
return (await transaction.getVoteStaple(...args));
|
|
@@ -77415,7 +77446,7 @@ exports.Testing = { findRDN, blockHashesFromVote, feeFromVote };
|
|
|
77415
77446
|
|
|
77416
77447
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
77417
77448
|
exports.version = void 0;
|
|
77418
|
-
exports.version = '0.14.
|
|
77449
|
+
exports.version = '0.14.3+gc0f4c96265aa999e6f32e3b21443d294bbf33806';
|
|
77419
77450
|
exports["default"] = exports.version;
|
|
77420
77451
|
|
|
77421
77452
|
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
---
|
|
2
|
+
Title: Getting Started
|
|
3
|
+
Category: Guides
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# KeetaNet Client SDK Getting Started
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
See the full documentation for the KeetaNet Client JavaScript/TypeScript SDK at [https://static.test.keeta.com/docs/](https://static.test.keeta.com/docs/).
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
The KeetaNet Client JavaScript/TypeScript SDK can be loaded with:
|
|
15
|
+
```bash
|
|
16
|
+
$ npm install @keetanetwork/keetanet-client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Concepts
|
|
20
|
+
### Accounts
|
|
21
|
+
|
|
22
|
+
{@link KeetaNetSDK.Referenced.Account | Accounts} in the KeetaNet SDK are the way in which key pairs or identifiers are
|
|
23
|
+
represented.
|
|
24
|
+
|
|
25
|
+
For key pairs, they securely store the private key (where applicable) and
|
|
26
|
+
provide operations like {@link KeetaNetSDK.Referenced.Account#sign | digital signing} and {@link KeetaNetSDK.Referenced.Account#verify | verification},
|
|
27
|
+
{@link KeetaNetSDK.Referenced.Account.fromSeed | key derivation from seed} and {@link KeetaNetSDK.Referenced.Account.seedFromPassphrase | passphrase}, and
|
|
28
|
+
{@link KeetaNetSDK.Referenced.Account#encrypt | encryption} and {@link KeetaNetSDK.Referenced.Account#decrypt | decryption} using ECIES.
|
|
29
|
+
|
|
30
|
+
For identifiers, they are used to represent the identity of a specific kind of
|
|
31
|
+
address, such as a Token, the Network Address, or a Storage account.
|
|
32
|
+
|
|
33
|
+
Additionally, for key pair accounts the key may be held internally or
|
|
34
|
+
externally using an external key provider. No particular external key provider
|
|
35
|
+
interface (e.g. PKCS#11) is specified but users may implement their own
|
|
36
|
+
provider using the {@link KeetaNetSDK.Referenced.ExternalKeyPair | ExternalKeyPair} interface.
|
|
37
|
+
|
|
38
|
+
### Blocks
|
|
39
|
+
|
|
40
|
+
{@link KeetaNetSDK.Referenced.Block | Blocks} are used within KeetaNet to represent a collection of operations
|
|
41
|
+
(transactions) by an account. They contain the {@link KeetaNetSDK.Referenced.Block#account | account identifier}, the
|
|
42
|
+
{@link KeetaNetSDK.Referenced.Block#network | network identifier}, the {@link KeetaNetSDK.Referenced.Block#previous | previous block identifier}, an optional
|
|
43
|
+
{@link KeetaNetSDK.Referenced.Block#signer | signer} (if different from the account), a {@link KeetaNetSDK.Referenced.Block#date | timestamp}, and a list of
|
|
44
|
+
{@link KeetaNetSDK.Referenced.Block#operations | operations}.
|
|
45
|
+
|
|
46
|
+
The block is digitally signed by the signer (if present, otherwise the account)
|
|
47
|
+
and the signature is included in the block. The block is identified by its
|
|
48
|
+
{@link KeetaNetSDK.Referenced.Block#hash | hash} which is the hash of the block
|
|
49
|
+
not including the signature.
|
|
50
|
+
|
|
51
|
+
The KeetaNet SDK also provides a block builder method which allows the user to
|
|
52
|
+
create blocks in an incremental fashion. The block builder is created using the
|
|
53
|
+
{@link KeetaNetSDK.Referenced.BlockBuilder | BlockBuilder} class, however in
|
|
54
|
+
most cases a {@link KeetaNetSDK.Referenced.UserClientBuilder | UserClientBuilder}
|
|
55
|
+
from a {@link KeetaNetSDK.UserClient#initBuilder | UserClient} should be used
|
|
56
|
+
because it will handle things like getting the correct network and previous
|
|
57
|
+
block hash.
|
|
58
|
+
|
|
59
|
+
### Operations
|
|
60
|
+
|
|
61
|
+
{@link KeetaNetSDK.Referenced.BlockOperation | Operations} describe the actions performed by an account on the ledger. They
|
|
62
|
+
are fundamentally composed of effects, which are the specific changes or
|
|
63
|
+
constraints performed on the ledger.
|
|
64
|
+
|
|
65
|
+
An example operation is a {@link KeetaNetSDK.Referenced.BlockOperationSEND | Send}
|
|
66
|
+
operation which has the effects of decrementing the balance of the sender,
|
|
67
|
+
incrementing the balance of the receiver, and validating that the sender's
|
|
68
|
+
balance does not drop below zero.
|
|
69
|
+
|
|
70
|
+
The KeetaNet SDK provides {@link KeetaNetSDK.Referenced.BlockOperation | a number of operations}
|
|
71
|
+
which are used to perform actions on the ledger.
|
|
72
|
+
|
|
73
|
+
### Votes
|
|
74
|
+
|
|
75
|
+
{@link KeetaNetSDK.Referenced.Vote | Votes} in KeetaNet are used for consensus forming among "representatives".
|
|
76
|
+
Each vote is an assertion by a representative that a specific group of blocks
|
|
77
|
+
(identified by their hashes) are valid and conform to the rules of the
|
|
78
|
+
ledger of that representative.
|
|
79
|
+
|
|
80
|
+
Votes are used to form a consensus on the state of the ledger and are
|
|
81
|
+
aggregated by the representatives to form a "vote staple". A vote staple is
|
|
82
|
+
a collection of votes and the blocks which are referenced by those vote.
|
|
83
|
+
|
|
84
|
+
Votes come in two flavors: temporary and permanent. Temporary votes are
|
|
85
|
+
used to get initial consensus on a set of blocks. A quorum of temporary votes
|
|
86
|
+
can be "traded in" for permanent votes.
|
|
87
|
+
|
|
88
|
+
When a temporary vote is issued by a representative the vote and block are
|
|
89
|
+
stored on the representative's "side ledger", which is a non-synchronized
|
|
90
|
+
portion of the ledger. The client can request a copy of the block from the
|
|
91
|
+
representative {@link KeetaNetSDK.Client#getPendingBlock | Client.getPendingBlock}
|
|
92
|
+
or {@link KeetaNetSDK.UserClient#pendingBlock | UserClient.pendingBlock} method,
|
|
93
|
+
or the {@link KeetaNetSDK.Client#getVoteStaple | Client.getVoteStaple} method to
|
|
94
|
+
with the "`side`" parameter set to `side` to retrieve the vote staple from the
|
|
95
|
+
representative's side ledger.
|
|
96
|
+
|
|
97
|
+
Additionally, the {@link KeetaNetSDK.UserClient#recover | UserClient.recover} method
|
|
98
|
+
can be used to query all known representatives for side ledger vote staples
|
|
99
|
+
to complete any partially completed consensus rounds.
|
|
100
|
+
|
|
101
|
+
### Vote Staples
|
|
102
|
+
|
|
103
|
+
{@link KeetaNetSDK.Referenced.VoteStaple | Vote Staples}, as discussed above, are a
|
|
104
|
+
collection of votes and the blocks. Every vote in a vote staple must be for the same
|
|
105
|
+
set of blocks in the same order.
|
|
106
|
+
|
|
107
|
+
Vote Staples are the unit of transaction in the KeetaNet network. The set of
|
|
108
|
+
blocks in a vote staple are applied altogether as a single atomic transaction
|
|
109
|
+
acting on the ledger.
|
|
110
|
+
|
|
111
|
+
### Networks
|
|
112
|
+
|
|
113
|
+
{@link KeetaNetSDK.Referenced.src/config.networksArray | Networks} in KeetaNet
|
|
114
|
+
a group of representative nodes and clients which all agree to a common set of
|
|
115
|
+
rules and initial ledger state. There can be many different networks, such as
|
|
116
|
+
the "test" network, "main" network, and "dev" network. Each network has its
|
|
117
|
+
own set of representatives and clients.
|
|
118
|
+
|
|
119
|
+
The network is identified within each block by the {@link KeetaNetSDK.Referenced.Block#network | network identifier}
|
|
120
|
+
property, which is an integer.
|
|
121
|
+
|
|
122
|
+
Each network also has a {@link KeetaNetSDK.UserClient.networkAddress | Network Address},
|
|
123
|
+
which is a special kind of account derived from the network identifier. The
|
|
124
|
+
purpose of the network address is to define permissions which apply to the
|
|
125
|
+
network as a whole, such as the permission to create tokens, or create storage
|
|
126
|
+
accounts.
|
|
127
|
+
|
|
128
|
+
### Tokens
|
|
129
|
+
|
|
130
|
+
{@link KeetaNetSDK.Referenced.AccountKeyAlgorithm.TOKEN | Tokens} in KeetaNet are a
|
|
131
|
+
special kind of account which is used to represent a fungible asset. Tokens can be
|
|
132
|
+
created using the {@link KeetaNetSDK.Referenced.BlockOperationCREATE_IDENTIFIER | Create Identifier}
|
|
133
|
+
method though the {@link KeetaNetSDK.Referenced.UserClientBuilder#generateIdentifier | UserClientBuilder.generateIdentifier}
|
|
134
|
+
method is recommended.
|
|
135
|
+
|
|
136
|
+
Each network also has a base token which is used for consensus and other
|
|
137
|
+
management functions. The base token can be thought of as the native currency
|
|
138
|
+
of the network and is derived from the network identifier.
|
|
139
|
+
|
|
140
|
+
### Ledger
|
|
141
|
+
|
|
142
|
+
The ledger within KeetaNet refers to a couple of different things:
|
|
143
|
+
|
|
144
|
+
- The live state of accounts and their balances of tokens, as well as other attributes
|
|
145
|
+
- The record of how that state came to be, represented by vote staples
|
|
146
|
+
|
|
147
|
+
#### The ledger state
|
|
148
|
+
|
|
149
|
+
The ledger state is the current state of all accounts and their balances of tokens,
|
|
150
|
+
it can be thought of like this:
|
|
151
|
+
|
|
152
|
+
| Account | Base Token | Token 1 | Token 2 | Token 3
|
|
153
|
+
| ------- | ---------- | ------- | ------- | -------
|
|
154
|
+
| kta1 | 1 | 100 | 200 | 300
|
|
155
|
+
| kta2 | 5 | | 0 | 3
|
|
156
|
+
| kta3 | | 90 | |
|
|
157
|
+
|
|
158
|
+
Where `kta1`, `kta2`, and `kta3` are the account identifiers, and the columns
|
|
159
|
+
represent the balance of that account for the base token and other tokens.
|
|
160
|
+
|
|
161
|
+
#### The ledger history
|
|
162
|
+
|
|
163
|
+
The ledger history is the record of how the ledger state came to be. It is
|
|
164
|
+
represented by the set of vote staples which have been applied to the ledger.
|
|
165
|
+
|
|
166
|
+
This is expressed in two different ways in the KeetaNet SDK
|
|
167
|
+
|
|
168
|
+
- The {@link KeetaNetSDK.UserClient#history | UserClient.history} method which returns a list of
|
|
169
|
+
{@link KeetaNetSDK.Referenced.VoteStaple | vote staples} which have affected
|
|
170
|
+
the given account.
|
|
171
|
+
- The {@link KeetaNetSDK.UserClient#chain | UserClient.chain} method which returns a list of
|
|
172
|
+
{@link KeetaNetSDK.Referenced.Block | blocks} which have been applied for a given
|
|
173
|
+
account.
|
|
174
|
+
|
|
175
|
+
These two differ in that the history method returns all vote staples which
|
|
176
|
+
affected an account, even if they were not issued by the account -- for
|
|
177
|
+
example if a transfer was made to the account, the history method would return
|
|
178
|
+
the vote staple which included the transfer, but the chain method would not
|
|
179
|
+
because it was not issued by the account.
|
|
180
|
+
|
|
181
|
+
Additionally there is a method to {@link KeetaNetSDK.UserClient.filterStapleOperations | filter a list of vote staples}
|
|
182
|
+
to a list of operations which are relevant to a specific account. This is useful
|
|
183
|
+
because the list of operations in a vote staple may include changes that are uninteresting
|
|
184
|
+
from an account perspective.
|
|
185
|
+
|
|
186
|
+
### Permissions
|
|
187
|
+
|
|
188
|
+
{@link KeetaNetSDK.Referenced.Permissions | Permissions} in KeetaNet are used
|
|
189
|
+
to allow users and operators to manage access to resources on the network.
|
|
190
|
+
They are used to control who can create tokens, create storage accounts, as well
|
|
191
|
+
as delegate permissions to other accounts.
|
|
192
|
+
|
|
193
|
+
There are two kinds of permissions:
|
|
194
|
+
|
|
195
|
+
- {@link KeetaNetSDK.Referenced.BaseSet | Base} permissions are the permissions which are
|
|
196
|
+
defined by the network. These are the permissions which the network representatives
|
|
197
|
+
will look at to grant or deny access
|
|
198
|
+
- {@link KeetaNetSDK.Referenced.ExternalSet | External} permissions are the permissions which
|
|
199
|
+
applications can define. These are the permissions which are defined by the
|
|
200
|
+
users of KeetaNet and the network representatives will not process them.
|
|
201
|
+
These are useful for applications which want to define their own permissions and in
|
|
202
|
+
the future may be used with Smart Contracts.
|
|
203
|
+
|
|
204
|
+
Additionally, permissions may be applied to a specific account or set as
|
|
205
|
+
default permissions on some the following resources:
|
|
206
|
+
|
|
207
|
+
- Network Account: `ACCESS`, `STORAGE_CREATE`, `TOKEN_ADMIN_CREATE`
|
|
208
|
+
- Token Accounts: `ACCESS`
|
|
209
|
+
- Storage Accounts: `ACCESS`, `STORAGE_CAN_HOLD`, `STORAGE_DEPOSIT`
|
|
210
|
+
|
|
211
|
+
Setting default permissions is done with the {@link KeetaNetSDK.UserClient#setInfo | UserClient.setInfo}
|
|
212
|
+
method. Setting permission on an account are set with the
|
|
213
|
+
{@link KeetaNetSDK.UserClient#updatePermissions | UserClient.updatePermissions} method.
|
|
214
|
+
|
|
215
|
+
#### Base Permissions
|
|
216
|
+
|
|
217
|
+
The base permissions are defined by the network and are used to control access
|
|
218
|
+
to the network. Each base permission has a {@link KeetaNetSDK.Referenced.BaseFlag | flag name}
|
|
219
|
+
which can be used to identify the permission. The base permissions are:
|
|
220
|
+
|
|
221
|
+
- `ACCESS` - The permission to access the resource it is granted on -- if this
|
|
222
|
+
permission is missing then no access to the resource is granted, this is
|
|
223
|
+
useful as to create deny-list or permit-list resources.
|
|
224
|
+
- `ADMIN` - The `ADMIN` permission allows the `principal` to perform all actions
|
|
225
|
+
on the resource, excluding deleting the resource and transferring ownership.
|
|
226
|
+
For example, administrators of Token resources can mint and burn tokens and
|
|
227
|
+
set the permissions of the token.
|
|
228
|
+
- `OWNER` - The owner permission grants all the privileges of the `ADMIN`
|
|
229
|
+
permission but also the ability to delete the resource and transfer
|
|
230
|
+
ownership. All resources have exactly 1 owner.
|
|
231
|
+
- `UPDATE_INFO` - The update info permission allows the `principal` to update the
|
|
232
|
+
information of the resource. See {@link KeetaNetSDK.UserClient#setInfo | UserClient.setInfo}
|
|
233
|
+
for more information on how to set the info.
|
|
234
|
+
- `STORAGE_CREATE` - This permission on the network account allows the
|
|
235
|
+
specified account to create storage accounts. As a default permission it
|
|
236
|
+
allows everyone to create storage accounts.
|
|
237
|
+
- `TOKEN_ADMIN_CREATE` - This permission on the network account allows the
|
|
238
|
+
specified account to create token accounts. As a default permission it
|
|
239
|
+
allows everyone to create token accounts.
|
|
240
|
+
- `TOKEN_ADMIN_SUPPLY` - This permission on a token account allows the specified
|
|
241
|
+
specified account to mint and burn tokens. This is useful for fungible tokens
|
|
242
|
+
where the supply can be changed.
|
|
243
|
+
- `TOKEN_ADMIN_MODIFY_BALANCE` - This permission on a token account allows the
|
|
244
|
+
specified specified account to modify the balance of holders of this token's
|
|
245
|
+
balance.
|
|
246
|
+
- `STORAGE_DEPOSIT` - This permission on a storage account allows the specified
|
|
247
|
+
specified account to deposit the specified tokens into the storage account.
|
|
248
|
+
- `STORAGE_CAN_HOLD` - This permission on a storage account allows the specified
|
|
249
|
+
specified account to hold the specified token in the storage account.
|
|
250
|
+
- `SEND_ON_BEHALF` - This permission of an account allows the specified principal
|
|
251
|
+
account to send the specified token on behalf of the account. This is useful for
|
|
252
|
+
shared accounts where multiple accounts can send on behalf of the account.
|
|
253
|
+
To use this feature see the {@link KeetaNetSDK.Referenced.UserClientConfig#signer | signer} option
|
|
254
|
+
to specify a different signatory for the transaction from the specified
|
|
255
|
+
{@link KeetaNetSDK.Referenced.UserClientConfig#account | account}.
|
|
256
|
+
- `PERMISSION_DELEGATE_ADD` - This permission grants a subset of the abilities
|
|
257
|
+
of the current account to some other account. Must be used with
|
|
258
|
+
{@link KeetaNetSDK.Referenced.AdjustMethod.ADD | AdjustMethod.ADD}.
|
|
259
|
+
- `PERMISSION_DELEGATE_REMOVE` - This permission revokes a subset of the abilities
|
|
260
|
+
that have been delegated. Must be used with {@link KeetaNetSDK.Referenced.AdjustMethod.SUBTRACT | AdjustMethod.SUBTRACT}
|
|
261
|
+
- `MANAGE_CERTIFICATE` - This permission allows the specified account to manage
|
|
262
|
+
the certificate of the account. This is used to set the certificate of the
|
|
263
|
+
account, which is used to verify the identity of the account.
|
|
264
|
+
|
|
265
|
+
### Clients
|
|
266
|
+
|
|
267
|
+
{@link KeetaNetSDK.UserClient | Clients} in the KeetaNet SDK are the ways in
|
|
268
|
+
which applications primarily interact with the KeetaNet network. There are
|
|
269
|
+
two different clients supported:
|
|
270
|
+
|
|
271
|
+
- {@link KeetaNetSDK.UserClient | UserClient} is the main client which is used to
|
|
272
|
+
interact with the network. It is used to send transactions, query the ledger,
|
|
273
|
+
and perform other operations through the {@link KeetaNetSDK.Referenced.UserClientBuilder | UserClientBuilder}.
|
|
274
|
+
- {@link KeetaNetSDK.Client | Client} is a lower level client which is used to
|
|
275
|
+
by the {@link KeetaNetSDK.UserClient | UserClient} to interact with the
|
|
276
|
+
network.
|
|
277
|
+
|
|
278
|
+
## Usage
|
|
279
|
+
|
|
280
|
+
The KeetaNet SDK is designed to be used in a variety of environments, including
|
|
281
|
+
NodeJS, the browser, and other JavaScript environments. It has TypeScript
|
|
282
|
+
type definitions.
|
|
283
|
+
|
|
284
|
+
### NodeJS
|
|
285
|
+
|
|
286
|
+
The KeetaNet SDK can be used in NodeJS by importing the package:
|
|
287
|
+
|
|
288
|
+
```javascript
|
|
289
|
+
import * as KeetaNet from '@keetanetwork/keetanet-client';
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
From there, the SDK can be used to create a {@link KeetaNetSDK.UserClient | UserClient} and
|
|
293
|
+
interact with the KeetaNet network. See the {@link KeetaNetSDK.UserClient | UserClient}
|
|
294
|
+
documentation for more information on how to use the client.
|
|
295
|
+
|
|
296
|
+
Many other functions needed to support usage of the SDK are also in the
|
|
297
|
+
`@keetanetwork/keetanet-client` package, such as the {@link KeetaNetSDK.Referenced.Account | Account}
|
|
298
|
+
class, which is used to represent key pairs and identifiers, and the
|
|
299
|
+
{@link KeetaNetSDK.Referenced.Block | Block} class, which is used to represent
|
|
300
|
+
blocks on the ledger -- these are all imported with the `KeetaNet` import
|
|
301
|
+
and accessed with the {@link KeetaNetSDK.lib} namespace.
|
|
302
|
+
|
|
303
|
+
### Browser
|
|
304
|
+
|
|
305
|
+
The KeetaNet SDK can be used in the browser by including the script tag:
|
|
306
|
+
|
|
307
|
+
```html
|
|
308
|
+
<script src="https://static.test.keeta.com/keetanet-browser.js"></script>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
The KeetaNet SDK can then be accessed using the `KeetaNet` global variable.
|
|
312
|
+
|
|
313
|
+
## Examples
|
|
314
|
+
### Basic usage (NodeJS)
|
|
315
|
+
|
|
316
|
+
The {@link KeetaNetSDK.UserClient} is the main entry point to interact with
|
|
317
|
+
the KeetaNet network. It is initialized with a network name and an account
|
|
318
|
+
using the {@link KeetaNetSDK.UserClient.fromNetwork} constructor.
|
|
319
|
+
|
|
320
|
+
```javascript
|
|
321
|
+
import * as KeetaNet from '@keetanetwork/keetanet-client';
|
|
322
|
+
|
|
323
|
+
const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true });
|
|
324
|
+
const account = KeetaNet.lib.Account.fromSeed(seed, 0);
|
|
325
|
+
const client = KeetaNet.UserClient.fromNetwork('test', account);
|
|
326
|
+
|
|
327
|
+
async function main() {
|
|
328
|
+
console.debug(await client.chain());
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
main().then(function() {
|
|
332
|
+
process.exit(0);
|
|
333
|
+
}, function(error) {
|
|
334
|
+
console.error(error);
|
|
335
|
+
process.exit(1);
|
|
336
|
+
});
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Basic usage (Browser)
|
|
340
|
+
|
|
341
|
+
The SDK can be loaded in the browser with a script tag:
|
|
342
|
+
```html
|
|
343
|
+
<html>
|
|
344
|
+
<head>
|
|
345
|
+
<script src="https://static.test.keeta.com/keetanet-browser.js"></script>
|
|
346
|
+
</head>
|
|
347
|
+
<body>
|
|
348
|
+
<script>
|
|
349
|
+
const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true });
|
|
350
|
+
const account = KeetaNet.lib.Account.fromSeed(seed, 0);
|
|
351
|
+
const client = KeetaNet.UserClient.fromNetwork('test', account);
|
|
352
|
+
|
|
353
|
+
client.chain().then(console.debug);
|
|
354
|
+
</script>
|
|
355
|
+
</body>
|
|
356
|
+
</html>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Full examples
|
|
360
|
+
- [Basic Example](./examples/basic/index.js)
|
|
361
|
+
- [Real World Assets with NFT](./examples/rwa-nft/index.js)
|
package/docs/assets/hierarchy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.hierarchyData = "
|
|
1
|
+
window.hierarchyData = "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"
|