@keetanetwork/keetanet-client 0.16.1 → 0.18.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/client/index-browser.d.ts +3 -2
- package/client/index-browser.js +800 -252
- package/client/index.d.ts +3 -2
- package/client/index.js +738 -175
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/KeetaNetSDK.Client.html +4 -4
- package/docs/classes/KeetaNetSDK.Referenced.Account.html +6 -3
- package/docs/classes/KeetaNetSDK.Referenced.BaseSet.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.BaseVoteBuilder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.Block.html +3 -3
- package/docs/classes/KeetaNetSDK.Referenced.BlockBuilder.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 +2 -2
- 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.IdempotentKey.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 +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetErrorBase.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerError.html +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerIdempotentKeyError.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.KeetaNetLedgerVoteError.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 +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.LedgerAtomicInterface.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PermissionSetHolder.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyExpiredVote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.PossiblyUnsignedBlock.html +3 -3
- 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.UnsignedBlock.html +3 -3
- package/docs/classes/KeetaNetSDK.Referenced.Vote.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.VoteBlockBundle.html +2 -2
- 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 +2 -2
- package/docs/classes/KeetaNetSDK.Referenced.VoteStapleHash.html +1 -1
- package/docs/classes/KeetaNetSDK.Referenced.src_lib_utils_buffer.BufferStorage.html +1 -1
- package/docs/classes/KeetaNetSDK.UserClient.html +4 -4
- package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.applyNamespace.html +5 -0
- package/docs/functions/KeetaNetSDK.Referenced.src_lib_utils_helper.getTypedObjectEntries.html +1 -0
- package/docs/hierarchy.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.AccountACLRow.html +11 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.AccountComputedEffect.html +4 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseACLRow.html +9 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.BaseAccountInfo.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.BaseIdentifierAccountInfo.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.BlockJSONOperationMODIFY_PERMISSIONS.html +2 -2
- 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.CertificateACLPrincipal.html +4 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.CertificateACLRow.html +11 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.CertificateComputedEffect.html +5 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.ComputedBlocksEffectFields.html +2 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.Constructor.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.DisposableTimingHandle.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256K1AccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ECDSA_SECP256R1AccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ED25519AccountInfo.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 +4 -4
- package/docs/interfaces/KeetaNetSDK.Referenced.ListACLsByEntityFilters.html +4 -0
- package/docs/interfaces/KeetaNetSDK.Referenced.ModifyTokenBalanceEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultiSigIdentifierCreateArguments.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.MultisigConfig.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.NetworkAccountInfo.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.PrincipalACLWithInfoParsed.html +2 -7
- package/docs/interfaces/KeetaNetSDK.Referenced.PublicKeyStorage.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.PublishOptions.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.RequestTokenReceiveEntry.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.StorageAccountInfo.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.TokenAccountInfo.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.VoteStapleJSON.html +2 -2
- package/docs/interfaces/KeetaNetSDK.Referenced.WithIsInstance.html +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.signOptionsType.html +16 -3
- 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/interfaces/KeetaNetSDK.Referenced.src_lib_utils_asn1.ASN1Struct.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.html +1 -1
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.html +1 -0
- package/docs/modules/KeetaNetSDK.Referenced.src_lib_utils_helper.html +1 -1
- package/docs/types/KeetaNetSDK.Referenced.ACLEntryUnparsed.html +1 -5
- package/docs/types/KeetaNetSDK.Referenced.ACLPermissionRequirement.html +2 -0
- package/docs/types/KeetaNetSDK.Referenced.ACLPrincipalType.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.ACLRow.html +2 -0
- package/docs/types/KeetaNetSDK.Referenced.ACLUpdate.html +5 -0
- package/docs/types/KeetaNetSDK.Referenced.ComputedBlockEffect.html +2 -0
- package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocks.html +2 -2
- package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocksByEntity.html +2 -0
- package/docs/types/KeetaNetSDK.Referenced.ModifyPermissionsPrincipal.html +1 -0
- package/docs/types/KeetaNetSDK.Referenced.ModifyPermissionsPrincipalInput.html +1 -0
- package/docs/variables/KeetaNetSDK.Referenced.BlockOperationASN1Schema.html +2 -2
- package/docs/variables/KeetaNetSDK.Referenced.FullLedgerBaseErrorCode.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.aclPrincipalType.html +1 -0
- package/docs/variables/KeetaNetSDK.Referenced.allFullErrorCodes.html +1 -1
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.KeetaNamespaceVersion.html +3 -0
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.MaxNamespaceLength.html +3 -0
- package/docs/variables/KeetaNetSDK.Referenced.src_lib_utils_domain-separation.namespacePrefixSchema.html +9 -0
- package/docs/variables/KeetaNetSDK.lib.html +2 -2
- package/lib/account.d.ts +37 -0
- package/lib/block/index.d.ts +14 -2
- package/lib/block/operations.d.ts +40 -4
- package/lib/error/account.d.ts +2 -2
- package/lib/error/block.d.ts +2 -2
- package/lib/error/index.d.ts +1 -1
- package/lib/error/ledger.d.ts +3 -3
- package/lib/error/vote.d.ts +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/ledger/common.d.ts +19 -5
- package/lib/ledger/db_dynamodb.d.ts +4 -4
- package/lib/ledger/db_postgres.d.ts +4 -4
- package/lib/ledger/db_spanner.d.ts +4 -4
- package/lib/ledger/db_spanner_helper.d.ts +24 -4
- package/lib/ledger/db_sqlite.d.ts +4 -4
- package/lib/ledger/effects.d.ts +17 -9
- package/lib/ledger/index.d.ts +16 -7
- package/lib/ledger/types.d.ts +38 -14
- package/lib/log/target_gcp.js +19 -17
- package/lib/utils/domain-separation.d.ts +31 -0
- package/lib/utils/external-keys/gcp-kms-wrapped.d.ts +85 -0
- package/lib/utils/external-keys/gcp-kms-wrapped.js +453 -0
- package/lib/utils/external-keys/gcp-kms.common.d.ts +17 -0
- package/lib/utils/external-keys/gcp-kms.d.ts +48 -0
- package/lib/utils/external-keys/gcp-kms.js +341 -0
- package/lib/utils/external-keys/passkey-prf.d.ts +43 -4
- package/lib/utils/external-keys/passkey-prf.js +113 -13
- package/lib/utils/helper.d.ts +1 -0
- package/lib/vote.d.ts +7 -1
- package/npm-shrinkwrap.json +44 -26
- package/package.json +1 -1
- package/version.d.ts +1 -1
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLEntry.html +0 -10
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLRow.html +0 -10
- package/docs/interfaces/KeetaNetSDK.Referenced.ACLUpdate.html +0 -12
- package/docs/interfaces/KeetaNetSDK.Referenced.ComputedBlockEffect.html +0 -4
- package/docs/types/KeetaNetSDK.Referenced.ComputedEffectOfBlocksByAccount.html +0 -2
package/client/index-browser.js
CHANGED
|
@@ -101235,6 +101235,7 @@ __webpack_require__.d(client_helper_namespaceObject, {
|
|
|
101235
101235
|
crypto: () => (client_helper_crypto),
|
|
101236
101236
|
debugPrintableObject: () => (client_debugPrintableObject),
|
|
101237
101237
|
env: () => (client_env),
|
|
101238
|
+
getTypedObjectEntries: () => (client_getTypedObjectEntries),
|
|
101238
101239
|
isBuffer: () => (client_isBuffer),
|
|
101239
101240
|
isIntegerOrBigInt: () => (client_isIntegerOrBigInt),
|
|
101240
101241
|
nonNullable: () => (client_nonNullable),
|
|
@@ -101332,6 +101333,16 @@ __webpack_require__.d(client_utils_asn1_namespaceObject, {
|
|
|
101332
101333
|
isValidSequenceSchema: () => (client_isValidSequenceSchema)
|
|
101333
101334
|
});
|
|
101334
101335
|
|
|
101336
|
+
// NAMESPACE OBJECT: ./src/lib/utils/domain-separation.ts
|
|
101337
|
+
var client_domain_separation_namespaceObject = {};
|
|
101338
|
+
__webpack_require__.r(client_domain_separation_namespaceObject);
|
|
101339
|
+
__webpack_require__.d(client_domain_separation_namespaceObject, {
|
|
101340
|
+
KeetaNamespaceVersion: () => (client_KeetaNamespaceVersion),
|
|
101341
|
+
MaxNamespaceLength: () => (client_MaxNamespaceLength),
|
|
101342
|
+
applyNamespace: () => (client_applyNamespace),
|
|
101343
|
+
namespacePrefixSchema: () => (client_namespacePrefixSchema)
|
|
101344
|
+
});
|
|
101345
|
+
|
|
101335
101346
|
// NAMESPACE OBJECT: ./src/lib/utils/conversion.ts
|
|
101336
101347
|
var client_conversion_namespaceObject = {};
|
|
101337
101348
|
__webpack_require__.r(client_conversion_namespaceObject);
|
|
@@ -105460,6 +105471,12 @@ function src_client_assertClassBrand(e, t, n) { if ("function" == typeof e ? e =
|
|
|
105460
105471
|
|
|
105461
105472
|
|
|
105462
105473
|
|
|
105474
|
+
|
|
105475
|
+
// Helper to get properly typed entries from an object
|
|
105476
|
+
function client_getTypedObjectEntries(obj) {
|
|
105477
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
105478
|
+
return Object.entries(obj);
|
|
105479
|
+
}
|
|
105463
105480
|
const client_helper_randomBytes = client_crypto_default().randomBytes.bind((client_crypto_default()));
|
|
105464
105481
|
const client_helper_randomUUID = (client_crypto_default()).randomUUID ? client_crypto_default().randomUUID.bind((client_crypto_default())) : function () {
|
|
105465
105482
|
return client_esm_browser_v4();
|
|
@@ -106337,6 +106354,58 @@ class src_client_BufferStorage {
|
|
|
106337
106354
|
client_BufferStorage = src_client_BufferStorage;
|
|
106338
106355
|
client_buffer_defineProperty(src_client_BufferStorage, "isInstance", client_checkableGenerator(client_BufferStorage));
|
|
106339
106356
|
|
|
106357
|
+
;// ./src/lib/error/base.ts
|
|
106358
|
+
var client_KeetaNetErrorBase;
|
|
106359
|
+
function client_base_defineProperty(e, r, t) { return (r = client_base_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
106360
|
+
function client_base_toPropertyKey(t) { var i = client_base_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
106361
|
+
function client_base_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
106362
|
+
|
|
106363
|
+
class src_client_KeetaNetErrorBase extends Error {
|
|
106364
|
+
constructor(code, message, validation) {
|
|
106365
|
+
super(message);
|
|
106366
|
+
const type = (validation === null || validation === void 0 ? void 0 : validation.type) || 'GENERIC';
|
|
106367
|
+
if (validation !== undefined) {
|
|
106368
|
+
const prefix = `${validation.type}_`;
|
|
106369
|
+
const validPrefix = code.startsWith(prefix);
|
|
106370
|
+
const withoutPrefix = code.substring(prefix.length);
|
|
106371
|
+
const validCode = validation.codes.includes(withoutPrefix);
|
|
106372
|
+
if (!validPrefix || !validCode) {
|
|
106373
|
+
throw new Error(`Invalid construction of KeetaNetError Type: ${validation.type} Code: ${code}, prefix ${prefix} valid ${validPrefix} valid code: ${validCode}`);
|
|
106374
|
+
}
|
|
106375
|
+
}
|
|
106376
|
+
this.code = code;
|
|
106377
|
+
this.type = type;
|
|
106378
|
+
}
|
|
106379
|
+
toJSON() {
|
|
106380
|
+
return {
|
|
106381
|
+
type: this.type,
|
|
106382
|
+
code: this.code,
|
|
106383
|
+
message: this.message
|
|
106384
|
+
};
|
|
106385
|
+
}
|
|
106386
|
+
}
|
|
106387
|
+
client_KeetaNetErrorBase = src_client_KeetaNetErrorBase;
|
|
106388
|
+
client_base_defineProperty(src_client_KeetaNetErrorBase, "isInstance", client_checkableGenerator(client_KeetaNetErrorBase, false));
|
|
106389
|
+
;// ./src/lib/error/account.ts
|
|
106390
|
+
var client_KeetaNetAccountError;
|
|
106391
|
+
function client_account_defineProperty(e, r, t) { return (r = client_account_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
106392
|
+
function client_account_toPropertyKey(t) { var i = client_account_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
106393
|
+
function client_account_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
106394
|
+
|
|
106395
|
+
|
|
106396
|
+
const client_AccountErrorType = 'ACCOUNT';
|
|
106397
|
+
const client_AccountErrorCodes = ['INVALID_PREFIX', 'INVALID_KEYTYPE', 'INVALID_KEYTYPE_EXTERNAL', 'PASSPHRASE_WEAK', 'INVALID_CONSTRUCTION', 'NO_IDENTIFIER_SIGN', 'NO_IDENTIFIER_VERIFY', 'NOT_ACCOUNT', 'NOT_IDENTIFIER', 'INVALID_IDENTIFIER_CONSTRUCTION', 'SEED_INDEX_UNDEFINED', 'SEED_INDEX_NEGATIVE', 'SEED_INDEX_NOT_INT', 'SEED_INDEX_TOO_LARGE', 'ENCRYPTION_NOT_SUPPORTED', 'NAMESPACE_EMPTY', 'NAMESPACE_TOO_LONG'];
|
|
106398
|
+
const client_FullAccountErrorCodes = client_AccountErrorCodes.map(code => `${client_AccountErrorType}_${code}`);
|
|
106399
|
+
class src_client_KeetaNetAccountError extends src_client_KeetaNetErrorBase {
|
|
106400
|
+
constructor(code, message) {
|
|
106401
|
+
super(code, message, {
|
|
106402
|
+
type: client_AccountErrorType,
|
|
106403
|
+
codes: client_AccountErrorCodes
|
|
106404
|
+
});
|
|
106405
|
+
}
|
|
106406
|
+
}
|
|
106407
|
+
client_KeetaNetAccountError = src_client_KeetaNetAccountError;
|
|
106408
|
+
client_account_defineProperty(src_client_KeetaNetAccountError, "isInstance", client_checkableGenerator(client_KeetaNetAccountError));
|
|
106340
106409
|
;// ./node_modules/pvutils/build/utils.es.js
|
|
106341
106410
|
/*!
|
|
106342
106411
|
Copyright (c) Peculiar Ventures, LLC
|
|
@@ -115204,6 +115273,58 @@ const client_Testing = {
|
|
|
115204
115273
|
ASN1IntegerToBigInt: client_jsIntegerToBigInt
|
|
115205
115274
|
}
|
|
115206
115275
|
};
|
|
115276
|
+
;// ./src/lib/utils/domain-separation.ts
|
|
115277
|
+
/* provided dependency */ var client_domain_separation_Buffer = __webpack_require__(8287)["Buffer"];
|
|
115278
|
+
|
|
115279
|
+
|
|
115280
|
+
|
|
115281
|
+
/**
|
|
115282
|
+
* Version for Keeta's domain separation namespace schema, encoded as the
|
|
115283
|
+
* `INTEGER` field of `namespacePrefixSchema`.
|
|
115284
|
+
*/
|
|
115285
|
+
const client_KeetaNamespaceVersion = 0;
|
|
115286
|
+
|
|
115287
|
+
/**
|
|
115288
|
+
* Maximum domain separation namespace length in bytes (for strings,
|
|
115289
|
+
* this is the UTF-8 byte length, not the character count).
|
|
115290
|
+
*/
|
|
115291
|
+
const client_MaxNamespaceLength = 255;
|
|
115292
|
+
|
|
115293
|
+
/**
|
|
115294
|
+
* Schema for the namespace prefix:
|
|
115295
|
+
*
|
|
115296
|
+
* ```asn1
|
|
115297
|
+
* NamespacePrefix ::= SEQUENCE {
|
|
115298
|
+
* version INTEGER,
|
|
115299
|
+
* namespace OCTET STRING,
|
|
115300
|
+
* data OCTET STRING
|
|
115301
|
+
* }
|
|
115302
|
+
* ```
|
|
115303
|
+
*/
|
|
115304
|
+
const client_namespacePrefixSchema = [client_ValidateASN1.IsInteger, client_ValidateASN1.IsOctetString, client_ValidateASN1.IsOctetString];
|
|
115305
|
+
|
|
115306
|
+
/**
|
|
115307
|
+
* Apply the `NamespacePrefix` domain separator to `data`.
|
|
115308
|
+
*
|
|
115309
|
+
* String namespaces are UTF-8 encoded; ArrayBuffer namespaces are used
|
|
115310
|
+
* verbatim. Namespace length MUST be 1-`MaxNamespaceLength` bytes after
|
|
115311
|
+
* encoding.
|
|
115312
|
+
*/
|
|
115313
|
+
function client_applyNamespace(namespace, data) {
|
|
115314
|
+
let namespaceBytes;
|
|
115315
|
+
if (typeof namespace === 'string') {
|
|
115316
|
+
namespaceBytes = new TextEncoder().encode(namespace);
|
|
115317
|
+
} else {
|
|
115318
|
+
namespaceBytes = new Uint8Array(namespace);
|
|
115319
|
+
}
|
|
115320
|
+
if (namespaceBytes.length === 0) {
|
|
115321
|
+
throw new src_client_KeetaNetAccountError('ACCOUNT_NAMESPACE_EMPTY', 'Domain separation namespace must not be empty');
|
|
115322
|
+
}
|
|
115323
|
+
if (namespaceBytes.length > client_MaxNamespaceLength) {
|
|
115324
|
+
throw new src_client_KeetaNetAccountError('ACCOUNT_NAMESPACE_TOO_LONG', `Domain separation namespace must be 1-${client_MaxNamespaceLength} bytes, got: ${namespaceBytes.length}`);
|
|
115325
|
+
}
|
|
115326
|
+
return client_JStoASN1([client_KeetaNamespaceVersion, client_domain_separation_Buffer.from(namespaceBytes), client_domain_separation_Buffer.from(data)]).toBER(false);
|
|
115327
|
+
}
|
|
115207
115328
|
;// ./src/lib/utils/conversion.ts
|
|
115208
115329
|
/* provided dependency */ var client_conversion_Buffer = __webpack_require__(8287)["Buffer"];
|
|
115209
115330
|
|
|
@@ -115352,7 +115473,7 @@ const client_baseValidationConfig = {
|
|
|
115352
115473
|
},
|
|
115353
115474
|
blockOperations: {
|
|
115354
115475
|
external: {
|
|
115355
|
-
maxLength:
|
|
115476
|
+
maxLength: 1024,
|
|
115356
115477
|
regex: /^[-_A-Za-z0-9+/= ]+$/,
|
|
115357
115478
|
canBeEmpty: true
|
|
115358
115479
|
},
|
|
@@ -115561,38 +115682,6 @@ function client_fromOffsetArray(setOffsets) {
|
|
|
115561
115682
|
return val;
|
|
115562
115683
|
}
|
|
115563
115684
|
client_bitfield_defineProperty(src_client_BitField, "isInstance", client_checkableGenerator(client_BitField));
|
|
115564
|
-
;// ./src/lib/error/base.ts
|
|
115565
|
-
var client_KeetaNetErrorBase;
|
|
115566
|
-
function client_base_defineProperty(e, r, t) { return (r = client_base_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
115567
|
-
function client_base_toPropertyKey(t) { var i = client_base_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
115568
|
-
function client_base_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
115569
|
-
|
|
115570
|
-
class src_client_KeetaNetErrorBase extends Error {
|
|
115571
|
-
constructor(code, message, validation) {
|
|
115572
|
-
super(message);
|
|
115573
|
-
const type = (validation === null || validation === void 0 ? void 0 : validation.type) || 'GENERIC';
|
|
115574
|
-
if (validation !== undefined) {
|
|
115575
|
-
const prefix = `${validation.type}_`;
|
|
115576
|
-
const validPrefix = code.startsWith(prefix);
|
|
115577
|
-
const withoutPrefix = code.substring(prefix.length);
|
|
115578
|
-
const validCode = validation.codes.includes(withoutPrefix);
|
|
115579
|
-
if (!validPrefix || !validCode) {
|
|
115580
|
-
throw new Error(`Invalid construction of KeetaNetError Type: ${validation.type} Code: ${code}, prefix ${prefix} valid ${validPrefix} valid code: ${validCode}`);
|
|
115581
|
-
}
|
|
115582
|
-
}
|
|
115583
|
-
this.code = code;
|
|
115584
|
-
this.type = type;
|
|
115585
|
-
}
|
|
115586
|
-
toJSON() {
|
|
115587
|
-
return {
|
|
115588
|
-
type: this.type,
|
|
115589
|
-
code: this.code,
|
|
115590
|
-
message: this.message
|
|
115591
|
-
};
|
|
115592
|
-
}
|
|
115593
|
-
}
|
|
115594
|
-
client_KeetaNetErrorBase = src_client_KeetaNetErrorBase;
|
|
115595
|
-
client_base_defineProperty(src_client_KeetaNetErrorBase, "isInstance", client_checkableGenerator(client_KeetaNetErrorBase, false));
|
|
115596
115685
|
;// ./src/lib/error/permissions.ts
|
|
115597
115686
|
var client_KeetaNetPermissionsError;
|
|
115598
115687
|
function client_permissions_defineProperty(e, r, t) { return (r = client_permissions_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -116208,7 +116297,7 @@ function client_block_toPrimitive(t, r) { if ("object" != typeof t || !t) return
|
|
|
116208
116297
|
|
|
116209
116298
|
|
|
116210
116299
|
const client_BlockErrorType = 'BLOCK';
|
|
116211
|
-
const client_BlockErrorCodes = ['AMOUNT_BELOW_ZERO', 'CANNOT_FORWARD_TO_SELF', 'CANNOT_SEND_NON_TOKEN', 'CERTIFICATE_SUBJECT_MISMATCH', 'EXACT_TRUE_WHEN_FORWARDING', 'EXTERNAL_INVALID', 'EXTERNAL_MISSING', 'EXTERNAL_TOO_LONG', 'GENERAL_FIELD_INVALID', 'IDENTIFIER_INVALID', 'IDENTIFIER_NEED_DEFAULT_PERMISSIONS', 'INTERMEDIATE_CERTIFICATES_ONLY_ADD', 'INVALID_ACCOUNT_TYPE', 'INVALID_CERTIFICATE_VALUE', 'INVALID_CREATE_IDENTIFIER_ARGS', 'INVALID_IDEMPOTENT_FORMAT', 'INVALID_IDEMPOTENT_LENGTH', 'INVALID_MULTISIG_QUORUM', 'INVALID_MULTISIG_SIGNER_COUNT', 'INVALID_MULTISIG_SIGNER_DEPTH', 'INVALID_MULTISIG_SIGNER_DUPLICATE', 'INVALID_PURPOSE_VALIDATION', 'INVALID_SIGNATURE', 'INVALID_SIGNER', 'INVALID_TYPE', 'INVALID_VERSION', 'NO_ADMIN_ON_TARGET', 'NO_DELEGATE_ADMIN', 'NO_DUPLICATE_CERTIFICATE_OPERATION', 'NO_IDENTIFIER_OP', 'NO_MODIFY_PERMISSION_DUPE', 'NO_MULTIPLE_SET_REP', 'NO_MULTISIG_OP', 'NO_TOKEN_OP', 'ONLY_IDENTIFIER_OP', 'ONLY_TOKEN_OP', 'PERMISSIONS_INVALID_DEFAULT', 'PERMISSIONS_INVALID_ENTITY', 'PERMISSIONS_INVALID_PRINCIPAL', 'PERMISSIONS_INVALID_TARGET', 'PREVIOUS_SELF', 'SUPPLY_INVALID', 'TOKEN_RECEIVE_DIFFERS', 'SIGNATURE_REQUIRED', 'SIGNATURE_PARAMETER_DIFFERS'];
|
|
116300
|
+
const client_BlockErrorCodes = ['AMOUNT_BELOW_ZERO', 'CANNOT_FORWARD_TO_SELF', 'CANNOT_SEND_NON_TOKEN', 'CERTIFICATE_SUBJECT_MISMATCH', 'EXACT_TRUE_WHEN_FORWARDING', 'EXTERNAL_INVALID', 'EXTERNAL_MISSING', 'EXTERNAL_TOO_LONG', 'GENERAL_FIELD_INVALID', 'IDENTIFIER_INVALID', 'IDENTIFIER_NEED_DEFAULT_PERMISSIONS', 'INTERMEDIATE_CERTIFICATES_ONLY_ADD', 'INVALID_ACCOUNT_TYPE', 'INVALID_CERTIFICATE_VALUE', 'INVALID_CREATE_IDENTIFIER_ARGS', 'INVALID_IDEMPOTENT_FORMAT', 'INVALID_IDEMPOTENT_LENGTH', 'INVALID_MULTISIG_QUORUM', 'INVALID_MULTISIG_SIGNER_COUNT', 'INVALID_MULTISIG_SIGNER_DEPTH', 'INVALID_MULTISIG_SIGNER_DUPLICATE', 'INVALID_PURPOSE_VALIDATION', 'INVALID_SIGNATURE', 'INVALID_SIGNER', 'INVALID_TYPE', 'INVALID_VERSION', 'INVALID_PRINCIPAL', 'NO_ADMIN_ON_TARGET', 'NO_DELEGATE_ADMIN', 'NO_DUPLICATE_CERTIFICATE_OPERATION', 'NO_IDENTIFIER_OP', 'NO_MODIFY_PERMISSION_DUPE', 'NO_MULTIPLE_SET_REP', 'NO_MULTISIG_OP', 'NO_TOKEN_OP', 'ONLY_IDENTIFIER_OP', 'ONLY_TOKEN_OP', 'PERMISSIONS_INVALID_DEFAULT', 'PERMISSIONS_INVALID_ENTITY', 'PERMISSIONS_INVALID_PRINCIPAL', 'PERMISSIONS_INVALID_TARGET', 'PREVIOUS_SELF', 'SUPPLY_INVALID', 'TOKEN_RECEIVE_DIFFERS', 'SIGNATURE_REQUIRED', 'SIGNATURE_PARAMETER_DIFFERS'];
|
|
116212
116301
|
const client_FullBlockErrorCodes = client_BlockErrorCodes.map(code => `${client_BlockErrorType}_${code}`);
|
|
116213
116302
|
class src_client_KeetaNetBlockError extends src_client_KeetaNetErrorBase {
|
|
116214
116303
|
constructor(code, message) {
|
|
@@ -117826,7 +117915,7 @@ function client_ledger_toPrimitive(t, r) { if ("object" != typeof t || !t) retur
|
|
|
117826
117915
|
|
|
117827
117916
|
|
|
117828
117917
|
const client_LedgerErrorType = 'LEDGER';
|
|
117829
|
-
const client_LedgerBaseErrorCodes = ['BLOCK_ALREADY_EXISTS', 'BLOCK_EXPIRED', 'TRANSACTION_ABORTED', 'INVALID_CHAIN', 'INVALID_NETWORK', 'INVALID_SUBNET', 'INVALID_PERMISSIONS', 'INVALID_OWNER_COUNT', 'INVALID_BALANCE', 'INVALID_SET_REP', 'OPERATION_NOT_SUPPORTED', 'NOT_EMPTY', 'PREVIOUS_ALREADY_USED', 'PREVIOUS_NOT_SEEN', 'SUCCESSOR_VOTE_EXISTS', 'INSUFFICIENT_VOTING_WEIGHT', 'INVALID_ACCOUNT_INFO_KEY', 'RECEIVE_NOT_MET', 'DUPLICATE_VOTE_FOUND', 'CANNOT_EXCHANGE_PERM_VOTE', 'TEMP_VOTE_INCLUDES_SELF', 'BLOCKS_DIFFER_FROM_VOTED_ON', 'NO_PERM_WITHOUT_SELF_TEMP', 'DUPLICATE_VOTE_ISSUER_FOUND', 'OTHER', 'MISSING_BLOCKS',
|
|
117918
|
+
const client_LedgerBaseErrorCodes = ['BLOCK_ALREADY_EXISTS', 'BLOCK_EXPIRED', 'TRANSACTION_ABORTED', 'INVALID_CHAIN', 'INVALID_NETWORK', 'INVALID_SUBNET', 'INVALID_PERMISSIONS', 'INVALID_OWNER_COUNT', 'INVALID_BALANCE', 'INVALID_SET_REP', 'INVALID_ACL_ROW_TYPE', 'OPERATION_NOT_SUPPORTED', 'NOT_EMPTY', 'PREVIOUS_ALREADY_USED', 'PREVIOUS_NOT_SEEN', 'SUCCESSOR_VOTE_EXISTS', 'INSUFFICIENT_VOTING_WEIGHT', 'INVALID_ACCOUNT_INFO_KEY', 'RECEIVE_NOT_MET', 'DUPLICATE_VOTE_FOUND', 'CANNOT_EXCHANGE_PERM_VOTE', 'TEMP_VOTE_INCLUDES_SELF', 'BLOCKS_DIFFER_FROM_VOTED_ON', 'NO_PERM_WITHOUT_SELF_TEMP', 'DUPLICATE_VOTE_ISSUER_FOUND', 'OTHER', 'MISSING_BLOCKS', 'CERTIFICATE_NOT_FOUND',
|
|
117830
117919
|
// Fee Errors
|
|
117831
117920
|
'FEE_AMOUNT_MISMATCH', 'FEE_TOKEN_MISMATCH', 'FEE_MISSING', 'MISSING_REQUIRED_FEE_BLOCK', 'MULTIPLE_FEE_BLOCK', 'VOTE_WITH_QUOTE', 'QUOTE_MISMATCH', 'REQUIRED_FEE_MISMATCH'];
|
|
117832
117921
|
|
|
@@ -117947,6 +118036,16 @@ function client_common_assertClassBrand(e, t, n) { if ("function" == typeof e ?
|
|
|
117947
118036
|
|
|
117948
118037
|
|
|
117949
118038
|
|
|
118039
|
+
function client_areACLPrincipalEqual(a, b) {
|
|
118040
|
+
if (client_lib_account.isInstance(a) || client_lib_account.isInstance(b)) {
|
|
118041
|
+
if (!client_lib_account.isInstance(a) || !client_lib_account.isInstance(b)) {
|
|
118042
|
+
return false;
|
|
118043
|
+
}
|
|
118044
|
+
return a.comparePublicKey(b);
|
|
118045
|
+
} else {
|
|
118046
|
+
return a.certificate.compareHexString(b.certificate) && a.certificateAccount.comparePublicKey(b.certificateAccount);
|
|
118047
|
+
}
|
|
118048
|
+
}
|
|
117950
118049
|
function client_findPermissionMatch(lookingFor, entries) {
|
|
117951
118050
|
const {
|
|
117952
118051
|
principal,
|
|
@@ -117955,7 +118054,8 @@ function client_findPermissionMatch(lookingFor, entries) {
|
|
|
117955
118054
|
} = lookingFor;
|
|
117956
118055
|
let foundRow;
|
|
117957
118056
|
for (const entry of entries) {
|
|
117958
|
-
|
|
118057
|
+
// If principals do not match, we can skip
|
|
118058
|
+
if (!client_areACLPrincipalEqual(principal, entry.principal)) {
|
|
117959
118059
|
continue;
|
|
117960
118060
|
}
|
|
117961
118061
|
|
|
@@ -118012,6 +118112,32 @@ function client_validateBlockSignerDepth(depth, network) {
|
|
|
118012
118112
|
}
|
|
118013
118113
|
}
|
|
118014
118114
|
|
|
118115
|
+
/**
|
|
118116
|
+
* Determines if an account type can delegate voting weight via SET_REP.
|
|
118117
|
+
*
|
|
118118
|
+
* Regular accounts (ECDSA_SECP256K1, ED25519, ECDSA_SECP256R1) can always delegate.
|
|
118119
|
+
* Among identifier accounts, only STORAGE accounts can delegate.
|
|
118120
|
+
* TOKEN, NETWORK, and MULTISIG identifier accounts cannot delegate.
|
|
118121
|
+
*
|
|
118122
|
+
* @param keyType - The account key algorithm type to check
|
|
118123
|
+
* @returns true if the account type can use SET_REP to delegate, false otherwise
|
|
118124
|
+
*
|
|
118125
|
+
*/
|
|
118126
|
+
function client_canDelegate(keyType) {
|
|
118127
|
+
// Regular accounts (non-identifiers) can always delegate
|
|
118128
|
+
if (!client_lib_account.isIdentifierKeyType(keyType)) {
|
|
118129
|
+
return true;
|
|
118130
|
+
}
|
|
118131
|
+
|
|
118132
|
+
// Among identifiers, only STORAGE can delegate
|
|
118133
|
+
if (keyType === client_AccountKeyAlgorithm.STORAGE) {
|
|
118134
|
+
return true;
|
|
118135
|
+
}
|
|
118136
|
+
|
|
118137
|
+
// Other identifier accounts cannot delegate
|
|
118138
|
+
return false;
|
|
118139
|
+
}
|
|
118140
|
+
|
|
118015
118141
|
/**
|
|
118016
118142
|
* Compute effects on the ledger from block effects
|
|
118017
118143
|
*/
|
|
@@ -118067,79 +118193,111 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
|
|
|
118067
118193
|
const resolved = await getAccountInfoPromises[accountPubKey];
|
|
118068
118194
|
return resolved;
|
|
118069
118195
|
};
|
|
118196
|
+
const getCertificatePromises = {};
|
|
118197
|
+
const getCertificate = async (certificateHash, account) => {
|
|
118198
|
+
const promiseKey = `${certificateHash.toString()}-${account.publicKeyString.get()}`;
|
|
118199
|
+
if (getCertificatePromises[promiseKey] === undefined) {
|
|
118200
|
+
getCertificatePromises[promiseKey] = storageProvider.getAccountCertificateByHash(transaction, account, certificateHash);
|
|
118201
|
+
}
|
|
118202
|
+
return await getCertificatePromises[promiseKey];
|
|
118203
|
+
};
|
|
118070
118204
|
const getPermissionPromises = {};
|
|
118071
|
-
const getPermissions = async (
|
|
118072
|
-
|
|
118205
|
+
const getPermissions = async (principal, entityList) => {
|
|
118206
|
+
let promiseKey;
|
|
118207
|
+
if (client_lib_account.isInstance(principal)) {
|
|
118208
|
+
promiseKey = `account-${principal.publicKeyString.get()}`;
|
|
118209
|
+
} else {
|
|
118210
|
+
promiseKey = `certificate-${principal.certificate.toString()}-${principal.certificateAccount.publicKeyString.get()}`;
|
|
118211
|
+
}
|
|
118073
118212
|
if (!entityList) {
|
|
118074
|
-
return await getPermissionPromises[
|
|
118213
|
+
return await getPermissionPromises[promiseKey];
|
|
118075
118214
|
}
|
|
118076
|
-
if (getPermissionPromises[
|
|
118215
|
+
if (getPermissionPromises[promiseKey] !== undefined) {
|
|
118077
118216
|
throw new Error('getPermissions() can only be called once per account');
|
|
118078
118217
|
}
|
|
118079
|
-
getPermissionPromises[
|
|
118080
|
-
return await getPermissionPromises[
|
|
118218
|
+
getPermissionPromises[promiseKey] = storageProvider.listACLsByPrincipal(transaction, principal, entityList);
|
|
118219
|
+
return await getPermissionPromises[promiseKey];
|
|
118081
118220
|
};
|
|
118082
118221
|
const prefetchPromises = [];
|
|
118083
|
-
for (const {
|
|
118084
|
-
|
|
118085
|
-
|
|
118086
|
-
|
|
118087
|
-
|
|
118088
|
-
|
|
118089
|
-
|
|
118090
|
-
|
|
118091
|
-
|
|
118092
|
-
|
|
118093
|
-
|
|
118094
|
-
const toReadEntity = new client_lib_account.Set();
|
|
118095
|
-
for (const permUpdate of (_fields$permissions = fields.permissions) !== null && _fields$permissions !== void 0 ? _fields$permissions : []) {
|
|
118096
|
-
var _fields$permissions;
|
|
118097
|
-
if (permUpdate.method === src_client_Block.AdjustMethod.SET || permUpdate.permissions === null) {
|
|
118098
|
-
toReadEntity.delete(permUpdate.entity);
|
|
118099
|
-
continue;
|
|
118100
|
-
}
|
|
118101
|
-
toReadEntity.add(permUpdate.entity);
|
|
118222
|
+
for (const effect of Object.values(effects)) {
|
|
118223
|
+
const fields = effect.fields;
|
|
118224
|
+
const toReadEntity = new client_lib_account.Set();
|
|
118225
|
+
for (const permUpdate of (_fields$permissions = fields.permissions) !== null && _fields$permissions !== void 0 ? _fields$permissions : []) {
|
|
118226
|
+
var _fields$permissions;
|
|
118227
|
+
if ((permUpdate.method === src_client_Block.AdjustMethod.ADD || permUpdate.method === src_client_Block.AdjustMethod.SET) && permUpdate.principalType === 'CERTIFICATE') {
|
|
118228
|
+
prefetchPromises.push(getCertificate(permUpdate.principal.certificate, permUpdate.principal.certificateAccount));
|
|
118229
|
+
}
|
|
118230
|
+
if (permUpdate.method === src_client_Block.AdjustMethod.SET || permUpdate.permissions === null) {
|
|
118231
|
+
toReadEntity.delete(permUpdate.entity);
|
|
118232
|
+
continue;
|
|
118102
118233
|
}
|
|
118103
|
-
|
|
118234
|
+
toReadEntity.add(permUpdate.entity);
|
|
118235
|
+
}
|
|
118236
|
+
let principal;
|
|
118237
|
+
if (effect.type === 'ACCOUNT') {
|
|
118238
|
+
principal = effect.account;
|
|
118239
|
+
} else {
|
|
118240
|
+
principal = {
|
|
118241
|
+
usingCertificate: true,
|
|
118242
|
+
certificate: effect.certificateHash,
|
|
118243
|
+
certificateAccount: effect.certificateAccount
|
|
118244
|
+
};
|
|
118104
118245
|
}
|
|
118105
|
-
|
|
118106
|
-
|
|
118107
|
-
|
|
118108
|
-
|
|
118109
|
-
requestedRep = true;
|
|
118110
|
-
prefetchPromises.push(getRep(account, getFinalNumericValues));
|
|
118111
|
-
prefetchPromises.push(getWeight(delegationField.delegateTo));
|
|
118246
|
+
|
|
118247
|
+
// Only prefetch the permissions if we are computing the permissions
|
|
118248
|
+
if (computePermissions) {
|
|
118249
|
+
prefetchPromises.push(getPermissions(principal, toReadEntity.toArray()));
|
|
118112
118250
|
}
|
|
118113
|
-
|
|
118114
|
-
|
|
118115
|
-
|
|
118116
|
-
|
|
118117
|
-
|
|
118118
|
-
|
|
118119
|
-
|
|
118120
|
-
|
|
118121
|
-
|
|
118122
|
-
|
|
118123
|
-
|
|
118124
|
-
|
|
118125
|
-
|
|
118126
|
-
|
|
118127
|
-
|
|
118128
|
-
|
|
118129
|
-
|
|
118130
|
-
|
|
118131
|
-
|
|
118132
|
-
|
|
118133
|
-
|
|
118134
|
-
|
|
118135
|
-
const
|
|
118136
|
-
|
|
118137
|
-
|
|
118138
|
-
|
|
118139
|
-
|
|
118140
|
-
|
|
118141
|
-
|
|
118142
|
-
|
|
118251
|
+
if (effect.type !== 'CERTIFICATE') {
|
|
118252
|
+
var _fields$supply, _effects$accountPubKe;
|
|
118253
|
+
const {
|
|
118254
|
+
account
|
|
118255
|
+
} = effect;
|
|
118256
|
+
|
|
118257
|
+
// Always fetch the supply from accountInfo if it's changing so we can validate the effect
|
|
118258
|
+
if (((_fields$supply = fields.supply) !== null && _fields$supply !== void 0 ? _fields$supply : []).length > 0 && (checkRangeConstraints || getFinalNumericValues)) {
|
|
118259
|
+
prefetchPromises.push(getAccountInfo(account));
|
|
118260
|
+
}
|
|
118261
|
+
const accountPubKey = account.publicKeyString.get();
|
|
118262
|
+
const delegationField = (_effects$accountPubKe = effects[accountPubKey]) === null || _effects$accountPubKe === void 0 ? void 0 : _effects$accountPubKe.fields.delegation;
|
|
118263
|
+
const isDelegating = delegationField !== undefined;
|
|
118264
|
+
let requestedRep = false;
|
|
118265
|
+
if (isDelegating && computeWeights && getFinalNumericValues && client_canDelegate(account.keyType)) {
|
|
118266
|
+
requestedRep = true;
|
|
118267
|
+
prefetchPromises.push(getRep(account, getFinalNumericValues));
|
|
118268
|
+
prefetchPromises.push(getWeight(delegationField.delegateTo));
|
|
118269
|
+
}
|
|
118270
|
+
const rollingChanges = {};
|
|
118271
|
+
for (const tokenPubKey in (_fields$balance = fields.balance) !== null && _fields$balance !== void 0 ? _fields$balance : {}) {
|
|
118272
|
+
var _fields$balance;
|
|
118273
|
+
for (const balanceUpdate of ((_fields$balance2 = fields.balance) !== null && _fields$balance2 !== void 0 ? _fields$balance2 : {})[tokenPubKey]) {
|
|
118274
|
+
var _fields$balance2;
|
|
118275
|
+
if (balanceUpdate.isReceive) {
|
|
118276
|
+
continue;
|
|
118277
|
+
}
|
|
118278
|
+
const {
|
|
118279
|
+
set,
|
|
118280
|
+
value
|
|
118281
|
+
} = balanceUpdate;
|
|
118282
|
+
const token = client_lib_account.fromPublicKeyString(tokenPubKey).assertKeyType(client_AccountKeyAlgorithm.TOKEN);
|
|
118283
|
+
if (rollingChanges[tokenPubKey] === undefined) {
|
|
118284
|
+
rollingChanges[tokenPubKey] = 0n;
|
|
118285
|
+
}
|
|
118286
|
+
if (set) {
|
|
118287
|
+
prefetchPromises.push(getPreviousBalance(token, token));
|
|
118288
|
+
rollingChanges[tokenPubKey] = value;
|
|
118289
|
+
} else {
|
|
118290
|
+
rollingChanges[tokenPubKey] += value;
|
|
118291
|
+
}
|
|
118292
|
+
const isBaseToken = baseToken.comparePublicKey(tokenPubKey);
|
|
118293
|
+
const possibleNegative = rollingChanges[tokenPubKey] < 0n && checkRangeConstraints;
|
|
118294
|
+
if (possibleNegative && checkRangeConstraints || set || getFinalNumericValues || isDelegating && computeWeights) {
|
|
118295
|
+
prefetchPromises.push(getPreviousBalance(account, token));
|
|
118296
|
+
}
|
|
118297
|
+
if (computeWeights && isBaseToken && client_canDelegate(account.keyType) && !requestedRep) {
|
|
118298
|
+
requestedRep = true;
|
|
118299
|
+
prefetchPromises.push(getRep(account, getFinalNumericValues));
|
|
118300
|
+
}
|
|
118143
118301
|
}
|
|
118144
118302
|
}
|
|
118145
118303
|
}
|
|
@@ -118242,34 +118400,56 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
|
|
|
118242
118400
|
newEntry.change += change;
|
|
118243
118401
|
supplies[tokenPubKey] = newEntry;
|
|
118244
118402
|
};
|
|
118245
|
-
for (const {
|
|
118246
|
-
|
|
118247
|
-
fields
|
|
118248
|
-
} of Object.values(effects)) {
|
|
118249
|
-
var _effects$accountPubKe2;
|
|
118250
|
-
const accountPubKey = account.publicKeyString.get();
|
|
118403
|
+
for (const effect of Object.values(effects)) {
|
|
118404
|
+
const fields = effect.fields;
|
|
118251
118405
|
for (const supplyChange of (_fields$supply2 = fields.supply) !== null && _fields$supply2 !== void 0 ? _fields$supply2 : []) {
|
|
118252
118406
|
var _fields$supply2;
|
|
118253
|
-
if (!account.isToken()) {
|
|
118407
|
+
if (effect.type !== 'ACCOUNT' || !effect.account.isToken()) {
|
|
118254
118408
|
throw new Error('Cannot modify supply of non-token account');
|
|
118255
118409
|
}
|
|
118256
|
-
await modifySupply(account, supplyChange.value);
|
|
118410
|
+
await modifySupply(effect.account, supplyChange.value);
|
|
118257
118411
|
}
|
|
118258
|
-
|
|
118259
|
-
|
|
118260
|
-
|
|
118261
|
-
|
|
118262
|
-
|
|
118263
|
-
|
|
118264
|
-
|
|
118265
|
-
|
|
118412
|
+
for (const permUpdate of (_fields$permissions2 = fields.permissions) !== null && _fields$permissions2 !== void 0 ? _fields$permissions2 : []) {
|
|
118413
|
+
var _fields$permissions2, _previousEntry$permis;
|
|
118414
|
+
let principal;
|
|
118415
|
+
if (effect.type === 'ACCOUNT') {
|
|
118416
|
+
principal = effect.account;
|
|
118417
|
+
if (!client_lib_account.isInstance(permUpdate.principal)) {
|
|
118418
|
+
throw new Error('permUpdate.principal should be an account for ACCOUNT type effects');
|
|
118419
|
+
}
|
|
118420
|
+
if (!permUpdate.principal.comparePublicKey(effect.account)) {
|
|
118421
|
+
throw new Error('permUpdate.principal should not differ current account');
|
|
118422
|
+
}
|
|
118423
|
+
} else {
|
|
118424
|
+
if (client_lib_account.isInstance(permUpdate.principal)) {
|
|
118425
|
+
throw new Error('permUpdate.principal should be a certificate for CERTIFICATE type effects');
|
|
118426
|
+
}
|
|
118427
|
+
if (!permUpdate.principal.certificate.compareHexString(effect.certificateHash)) {
|
|
118428
|
+
throw new Error('permUpdate.principal should not differ current certificate');
|
|
118429
|
+
}
|
|
118430
|
+
principal = {
|
|
118431
|
+
usingCertificate: true,
|
|
118432
|
+
certificate: effect.certificateHash,
|
|
118433
|
+
certificateAccount: effect.certificateAccount
|
|
118434
|
+
};
|
|
118435
|
+
if (permUpdate.method === src_client_Block.AdjustMethod.ADD || permUpdate.method === src_client_Block.AdjustMethod.SET) {
|
|
118436
|
+
const certificate = await getCertificate(permUpdate.principal.certificate, permUpdate.principal.certificateAccount);
|
|
118437
|
+
if (!certificate) {
|
|
118438
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_CERTIFICATE_NOT_FOUND', `Certificate with hash ${permUpdate.principal.certificate.toString()} for account ${permUpdate.principal.certificateAccount.publicKeyString.get()} not found`);
|
|
118439
|
+
}
|
|
118440
|
+
}
|
|
118441
|
+
}
|
|
118442
|
+
|
|
118443
|
+
// If not computing permissions, we only need to validate certificate existence
|
|
118444
|
+
if (!computePermissions) {
|
|
118445
|
+
continue;
|
|
118266
118446
|
}
|
|
118267
118447
|
if (permUpdate.method === src_client_Block.AdjustMethod.SET || permUpdate.permissions === null) {
|
|
118268
118448
|
permissions.push(permUpdate);
|
|
118269
118449
|
continue;
|
|
118270
118450
|
}
|
|
118271
118451
|
let newPermissions;
|
|
118272
|
-
const previousEntry = client_findPermissionMatch(permUpdate, await getPermissions(
|
|
118452
|
+
const previousEntry = client_findPermissionMatch(permUpdate, await getPermissions(principal));
|
|
118273
118453
|
const previousPermissions = (_previousEntry$permis = previousEntry === null || previousEntry === void 0 ? void 0 : previousEntry.permissions) !== null && _previousEntry$permis !== void 0 ? _previousEntry$permis : new client_permissions_Permissions();
|
|
118274
118454
|
switch (permUpdate.method) {
|
|
118275
118455
|
case src_client_Block.AdjustMethod.ADD:
|
|
@@ -118285,14 +118465,19 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
|
|
|
118285
118465
|
permissions: newPermissions
|
|
118286
118466
|
});
|
|
118287
118467
|
}
|
|
118288
|
-
|
|
118289
|
-
|
|
118290
|
-
if (
|
|
118291
|
-
|
|
118292
|
-
|
|
118293
|
-
|
|
118294
|
-
if (
|
|
118295
|
-
await
|
|
118468
|
+
let isDelegating;
|
|
118469
|
+
let delegationField;
|
|
118470
|
+
if (effect.type === 'ACCOUNT') {
|
|
118471
|
+
var _effects$effect$accou;
|
|
118472
|
+
delegationField = (_effects$effect$accou = effects[effect.account.publicKeyString.get()]) === null || _effects$effect$accou === void 0 ? void 0 : _effects$effect$accou.fields.delegation;
|
|
118473
|
+
isDelegating = delegationField !== undefined;
|
|
118474
|
+
if (isDelegating && delegationField && client_canDelegate(effect.account.keyType) && computeWeights) {
|
|
118475
|
+
const currentDelegation = await getRep(effect.account, getFinalNumericValues);
|
|
118476
|
+
const previousBalance = await getPreviousBalance(effect.account, baseToken);
|
|
118477
|
+
await modifyWeight(delegationField.delegateTo, previousBalance);
|
|
118478
|
+
if (currentDelegation) {
|
|
118479
|
+
await modifyWeight(currentDelegation, -1n * previousBalance);
|
|
118480
|
+
}
|
|
118296
118481
|
}
|
|
118297
118482
|
}
|
|
118298
118483
|
const receivable = {};
|
|
@@ -118301,6 +118486,9 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
|
|
|
118301
118486
|
const tokenAcct = client_lib_account.fromPublicKeyString(tokenPubKey).assertKeyType(client_AccountKeyAlgorithm.TOKEN);
|
|
118302
118487
|
for (const balanceUpdate of ((_fields$balance4 = fields.balance) !== null && _fields$balance4 !== void 0 ? _fields$balance4 : {})[tokenPubKey]) {
|
|
118303
118488
|
var _fields$balance4;
|
|
118489
|
+
if (effect.type !== 'ACCOUNT') {
|
|
118490
|
+
throw new Error('Only accounts can have balance changes');
|
|
118491
|
+
}
|
|
118304
118492
|
const {
|
|
118305
118493
|
isReceive,
|
|
118306
118494
|
value,
|
|
@@ -118308,7 +118496,7 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
|
|
|
118308
118496
|
} = balanceUpdate;
|
|
118309
118497
|
if (isReceive) {
|
|
118310
118498
|
const receiveFromPubKey = otherAccount.publicKeyString.get();
|
|
118311
|
-
const previousEntry = getBalanceEntry(account, tokenAcct);
|
|
118499
|
+
const previousEntry = getBalanceEntry(effect.account, tokenAcct);
|
|
118312
118500
|
if (previousEntry.receiveValidated === false) {
|
|
118313
118501
|
continue;
|
|
118314
118502
|
}
|
|
@@ -118325,15 +118513,15 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
|
|
|
118325
118513
|
} else {
|
|
118326
118514
|
receiveValid = value <= receivableAmount;
|
|
118327
118515
|
}
|
|
118328
|
-
balances[
|
|
118516
|
+
balances[effect.account.publicKeyString.get()][tokenPubKey].receiveValidated = receiveValid;
|
|
118329
118517
|
continue;
|
|
118330
118518
|
}
|
|
118331
118519
|
let balanceChange;
|
|
118332
118520
|
if (balanceUpdate.set) {
|
|
118333
|
-
balanceChange = await modifyBalance(account, tokenAcct, value, true);
|
|
118521
|
+
balanceChange = await modifyBalance(effect.account, tokenAcct, value, true);
|
|
118334
118522
|
await modifyBalance(tokenAcct, tokenAcct, -1n * balanceChange, false);
|
|
118335
118523
|
} else {
|
|
118336
|
-
balanceChange = await modifyBalance(account, tokenAcct, value, false);
|
|
118524
|
+
balanceChange = await modifyBalance(effect.account, tokenAcct, value, false);
|
|
118337
118525
|
}
|
|
118338
118526
|
if (balanceUpdate.receivable) {
|
|
118339
118527
|
const otherAccountPubKey = otherAccount.publicKeyString.get();
|
|
@@ -118348,11 +118536,14 @@ async function client_computeLedgerEffect(options, effects, storageProvider, net
|
|
|
118348
118536
|
receivable[otherAccountPubKey][tokenPubKey] += balanceChange;
|
|
118349
118537
|
}
|
|
118350
118538
|
const isBaseToken = baseToken.comparePublicKey(tokenAcct);
|
|
118351
|
-
if (isBaseToken && account.
|
|
118539
|
+
if (isBaseToken && client_canDelegate(effect.account.keyType) && computeWeights) {
|
|
118352
118540
|
if (isDelegating) {
|
|
118541
|
+
if (!delegationField) {
|
|
118542
|
+
throw new Error('delegationField should be defined if isDelegating is true');
|
|
118543
|
+
}
|
|
118353
118544
|
await modifyWeight(delegationField.delegateTo, balanceChange);
|
|
118354
118545
|
} else {
|
|
118355
|
-
const currentRep = await getRep(account);
|
|
118546
|
+
const currentRep = await getRep(effect.account);
|
|
118356
118547
|
if (currentRep) {
|
|
118357
118548
|
await modifyWeight(currentRep, balanceChange);
|
|
118358
118549
|
}
|
|
@@ -118774,6 +118965,9 @@ function client_operationTypeToNumber(str) {
|
|
|
118774
118965
|
}
|
|
118775
118966
|
return type;
|
|
118776
118967
|
}
|
|
118968
|
+
const client_ModifyPermissionsPrincipalContextSpecificTagValues = {
|
|
118969
|
+
CERTIFICATE: 1
|
|
118970
|
+
};
|
|
118777
118971
|
function client_makeEncodeDecodePermission(emptyValue) {
|
|
118778
118972
|
return {
|
|
118779
118973
|
encode: data => {
|
|
@@ -118869,7 +119063,52 @@ const client_BlockOperationASN1SchemaBase = {
|
|
|
118869
119063
|
}],
|
|
118870
119064
|
'MODIFY_PERMISSIONS': [{
|
|
118871
119065
|
name: 'principal',
|
|
118872
|
-
schema:
|
|
119066
|
+
schema: {
|
|
119067
|
+
choice: [client_ValidateASN1.IsOctetString, {
|
|
119068
|
+
type: 'context',
|
|
119069
|
+
kind: 'explicit',
|
|
119070
|
+
value: client_ModifyPermissionsPrincipalContextSpecificTagValues.CERTIFICATE,
|
|
119071
|
+
contains: [/* Certificate Hash */
|
|
119072
|
+
client_ValidateASN1.IsOctetString, /* Certificate Issued To Account */
|
|
119073
|
+
client_ValidateASN1.IsOctetString]
|
|
119074
|
+
}]
|
|
119075
|
+
},
|
|
119076
|
+
encode(data) {
|
|
119077
|
+
if (client_lib_account.isInstance(data)) {
|
|
119078
|
+
return data.publicKeyAndType;
|
|
119079
|
+
} else if (data.usingCertificate) {
|
|
119080
|
+
return {
|
|
119081
|
+
type: 'context',
|
|
119082
|
+
kind: 'explicit',
|
|
119083
|
+
value: client_ModifyPermissionsPrincipalContextSpecificTagValues.CERTIFICATE,
|
|
119084
|
+
contains: [data.certificateHash.getBuffer(), data.certificateAccount.publicKeyAndType]
|
|
119085
|
+
};
|
|
119086
|
+
} else {
|
|
119087
|
+
throw new Error('Invalid principal type for MODIFY_PERMISSIONS operation');
|
|
119088
|
+
}
|
|
119089
|
+
},
|
|
119090
|
+
decode(data) {
|
|
119091
|
+
if (client_isBuffer(data)) {
|
|
119092
|
+
return client_lib_account.fromPublicKeyAndType(data);
|
|
119093
|
+
} else if (client_ASN1CheckUtilities.isASN1ContextTag(data, 'explicit')) {
|
|
119094
|
+
if (data.value === client_ModifyPermissionsPrincipalContextSpecificTagValues.CERTIFICATE) {
|
|
119095
|
+
if (!Array.isArray(data.contains) || data.contains.length !== 2) {
|
|
119096
|
+
throw new Error('Invalid principal data for MODIFY_PERMISSIONS operation');
|
|
119097
|
+
}
|
|
119098
|
+
const certificateHashData = data.contains[0];
|
|
119099
|
+
const certificateAccountData = data.contains[1];
|
|
119100
|
+
if (!client_isBuffer(certificateHashData) || !client_isBuffer(certificateAccountData)) {
|
|
119101
|
+
throw new Error('Invalid certificate hash data for MODIFY_PERMISSIONS operation');
|
|
119102
|
+
}
|
|
119103
|
+
return {
|
|
119104
|
+
usingCertificate: true,
|
|
119105
|
+
certificateHash: new src_client_CertificateHash(client_bufferToArrayBuffer(certificateHashData)),
|
|
119106
|
+
certificateAccount: client_lib_account.fromPublicKeyAndType(certificateAccountData)
|
|
119107
|
+
};
|
|
119108
|
+
}
|
|
119109
|
+
}
|
|
119110
|
+
throw new Error('Invalid principal data for MODIFY_PERMISSIONS operation');
|
|
119111
|
+
}
|
|
118873
119112
|
}, {
|
|
118874
119113
|
name: 'method',
|
|
118875
119114
|
schema: client_ValidateASN1.IsInteger
|
|
@@ -119370,8 +119609,8 @@ class src_client_BlockOperationSET_REP extends src_client_BlockOperation {
|
|
|
119370
119609
|
const {
|
|
119371
119610
|
block
|
|
119372
119611
|
} = context;
|
|
119373
|
-
if (block.account.
|
|
119374
|
-
throw new src_client_KeetaNetBlockError('BLOCK_NO_IDENTIFIER_OP',
|
|
119612
|
+
if (!client_canDelegate(block.account.keyType)) {
|
|
119613
|
+
throw new src_client_KeetaNetBlockError('BLOCK_NO_IDENTIFIER_OP', `${client_AccountKeyAlgorithm[block.account.keyType]} accounts cannot use SET_REP`);
|
|
119375
119614
|
}
|
|
119376
119615
|
if (this.to.isIdentifier()) {
|
|
119377
119616
|
throw new src_client_KeetaNetBlockError('BLOCK_NO_IDENTIFIER_OP', 'Cannot delegate to an identifier');
|
|
@@ -119609,10 +119848,6 @@ class src_client_BlockOperationSET_INFO extends src_client_BlockOperation {
|
|
|
119609
119848
|
return client_toJSONSerializable(val);
|
|
119610
119849
|
}
|
|
119611
119850
|
}
|
|
119612
|
-
|
|
119613
|
-
/**
|
|
119614
|
-
* Set Permissions Operation
|
|
119615
|
-
*/
|
|
119616
119851
|
client_BlockOperationSET_INFO = src_client_BlockOperationSET_INFO;
|
|
119617
119852
|
function client_validateNameDesc(field, value, network) {
|
|
119618
119853
|
const {
|
|
@@ -119631,6 +119866,9 @@ function client_validateNameDesc(field, value, network) {
|
|
|
119631
119866
|
return;
|
|
119632
119867
|
}
|
|
119633
119868
|
client_operations_defineProperty(src_client_BlockOperationSET_INFO, "isInstance", client_checkableGenerator(client_BlockOperationSET_INFO));
|
|
119869
|
+
/**
|
|
119870
|
+
* Set Permissions Operation
|
|
119871
|
+
*/
|
|
119634
119872
|
var client_principal = /*#__PURE__*/new WeakMap();
|
|
119635
119873
|
var client_target = /*#__PURE__*/new WeakMap();
|
|
119636
119874
|
var client_method2 = /*#__PURE__*/new WeakMap();
|
|
@@ -119648,7 +119886,7 @@ class src_client_BlockOperationMODIFY_PERMISSIONS extends src_client_BlockOperat
|
|
|
119648
119886
|
if (input.type !== client_OperationType.MODIFY_PERMISSIONS) {
|
|
119649
119887
|
throw new src_client_KeetaNetBlockError('BLOCK_INVALID_TYPE', 'Invalid construction of BlockJSONOperationMODIFY_PERMISSIONS');
|
|
119650
119888
|
}
|
|
119651
|
-
client_operations_classPrivateFieldSet(client_principal, this, this.
|
|
119889
|
+
client_operations_classPrivateFieldSet(client_principal, this, client_operations_assertClassBrand(client_BlockOperationMODIFY_PERMISSIONS_brand, this, client_computePrincipal).call(this, input.principal));
|
|
119652
119890
|
client_operations_classPrivateFieldSet(client_target, this, client_lib_account.toAccount(input.target));
|
|
119653
119891
|
client_operations_classPrivateFieldSet(client_method2, this, client_toAdjustMethod(input.method));
|
|
119654
119892
|
client_operations_classPrivateFieldSet(client_permissions, this, client_operations_assertClassBrand(client_BlockOperationMODIFY_PERMISSIONS_brand, this, client_computePermissions).call(this, input.permissions));
|
|
@@ -119696,8 +119934,15 @@ class src_client_BlockOperationMODIFY_PERMISSIONS extends src_client_BlockOperat
|
|
|
119696
119934
|
base
|
|
119697
119935
|
} = this.permissions;
|
|
119698
119936
|
const baseFlagsString = `[${base.flags.join(',')}]`;
|
|
119699
|
-
if (
|
|
119700
|
-
|
|
119937
|
+
if (client_lib_account.isInstance(this.principal)) {
|
|
119938
|
+
if (!base.checkAccountMatchesGroup('principal', this.principal)) {
|
|
119939
|
+
throw new src_client_KeetaNetBlockError('BLOCK_PERMISSIONS_INVALID_PRINCIPAL', `Incorrect principal for flags ${baseFlagsString}`);
|
|
119940
|
+
}
|
|
119941
|
+
} else {
|
|
119942
|
+
// If the principal is not an account, we only allow default permissions to be issued by a certificate principal
|
|
119943
|
+
if (!base.isValidForDefault) {
|
|
119944
|
+
throw new src_client_KeetaNetBlockError('BLOCK_PERMISSIONS_INVALID_DEFAULT', 'Invalid permissions, cannot use certificate principal with non-default permissions');
|
|
119945
|
+
}
|
|
119701
119946
|
}
|
|
119702
119947
|
if (this.target && !base.checkAccountMatchesGroup('target', this.target)) {
|
|
119703
119948
|
throw new src_client_KeetaNetBlockError('BLOCK_PERMISSIONS_INVALID_TARGET', `Incorrect target for flags ${baseFlagsString}`);
|
|
@@ -119725,7 +119970,12 @@ class src_client_BlockOperationMODIFY_PERMISSIONS extends src_client_BlockOperat
|
|
|
119725
119970
|
target,
|
|
119726
119971
|
method
|
|
119727
119972
|
} = operation;
|
|
119728
|
-
|
|
119973
|
+
let principalKey;
|
|
119974
|
+
if (client_lib_account.isInstance(principal)) {
|
|
119975
|
+
principalKey = principal.publicKeyString.get();
|
|
119976
|
+
} else {
|
|
119977
|
+
principalKey = `cert:${principal.certificateHash.get()}:${principal.certificateAccount.publicKeyString.get()}`;
|
|
119978
|
+
}
|
|
119729
119979
|
const targetKey = (target !== null && target !== void 0 ? target : block.account).publicKeyString.get();
|
|
119730
119980
|
if (!foundPrevious[principalKey]) {
|
|
119731
119981
|
foundPrevious[principalKey] = {};
|
|
@@ -119755,6 +120005,26 @@ class src_client_BlockOperationMODIFY_PERMISSIONS extends src_client_BlockOperat
|
|
|
119755
120005
|
* Token Supply operation
|
|
119756
120006
|
*/
|
|
119757
120007
|
client_BlockOperationMODIFY_PERMISSIONS = src_client_BlockOperationMODIFY_PERMISSIONS;
|
|
120008
|
+
function client_computePrincipal(principal) {
|
|
120009
|
+
if (typeof principal === 'string' || client_lib_account.isInstance(principal)) {
|
|
120010
|
+
return this.computeTo(principal);
|
|
120011
|
+
} else if (principal.usingCertificate) {
|
|
120012
|
+
const certificateAccount = client_lib_account.toAccount(principal.certificateAccount);
|
|
120013
|
+
let certificateHash;
|
|
120014
|
+
if (src_client_CertificateHash.isInstance(principal.certificateHash)) {
|
|
120015
|
+
certificateHash = principal.certificateHash;
|
|
120016
|
+
} else {
|
|
120017
|
+
certificateHash = new src_client_CertificateHash(principal.certificateHash);
|
|
120018
|
+
}
|
|
120019
|
+
return {
|
|
120020
|
+
usingCertificate: true,
|
|
120021
|
+
certificateHash,
|
|
120022
|
+
certificateAccount
|
|
120023
|
+
};
|
|
120024
|
+
} else {
|
|
120025
|
+
throw new src_client_KeetaNetBlockError('BLOCK_INVALID_PRINCIPAL', 'Invalid principal for MODIFY_PERMISSIONS');
|
|
120026
|
+
}
|
|
120027
|
+
}
|
|
119758
120028
|
function client_computePermissions(permissions) {
|
|
119759
120029
|
if (!permissions) {
|
|
119760
120030
|
return null;
|
|
@@ -121215,8 +121485,11 @@ class src_client_UnsignedBlock extends src_client_PossiblyUnsignedBlock {
|
|
|
121215
121485
|
async seal() {
|
|
121216
121486
|
const signers = src_client_UnsignedBlock.getSortedRequiredSigners(this.signer);
|
|
121217
121487
|
const hash = this.hash;
|
|
121488
|
+
const ancillaryData = this.toBytes(false);
|
|
121218
121489
|
const signatures = await Promise.all(signers.map(async function (signer) {
|
|
121219
|
-
const signature = await signer.sign(hash.getBuffer()
|
|
121490
|
+
const signature = await signer.sign(hash.getBuffer(), {
|
|
121491
|
+
ancillaryData
|
|
121492
|
+
});
|
|
121220
121493
|
return signature.getBuffer();
|
|
121221
121494
|
}));
|
|
121222
121495
|
const shared = {
|
|
@@ -121640,26 +121913,6 @@ client_lib_block_defineProperty(src_client_BlockBuilder, "Operation", src_client
|
|
|
121640
121913
|
client_lib_block_defineProperty(src_client_BlockBuilder, "NO_PREVIOUS", src_client_Block.NO_PREVIOUS);
|
|
121641
121914
|
src_client_Block.Builder = src_client_BlockBuilder;
|
|
121642
121915
|
/* harmony default export */ const client_lib_block = (src_client_Block);
|
|
121643
|
-
;// ./src/lib/error/account.ts
|
|
121644
|
-
var client_KeetaNetAccountError;
|
|
121645
|
-
function client_account_defineProperty(e, r, t) { return (r = client_account_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
121646
|
-
function client_account_toPropertyKey(t) { var i = client_account_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
121647
|
-
function client_account_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
121648
|
-
|
|
121649
|
-
|
|
121650
|
-
const client_AccountErrorType = 'ACCOUNT';
|
|
121651
|
-
const client_AccountErrorCodes = ['INVALID_PREFIX', 'INVALID_KEYTYPE', 'INVALID_KEYTYPE_EXTERNAL', 'PASSPHRASE_WEAK', 'INVALID_CONSTRUCTION', 'NO_IDENTIFIER_SIGN', 'NO_IDENTIFIER_VERIFY', 'INVALID_IDENTIFIER_CONSTRUCTION', 'SEED_INDEX_UNDEFINED', 'SEED_INDEX_NEGATIVE', 'SEED_INDEX_NOT_INT', 'SEED_INDEX_TOO_LARGE', 'ENCRYPTION_NOT_SUPPORTED'];
|
|
121652
|
-
const client_FullAccountErrorCodes = client_AccountErrorCodes.map(code => `${client_AccountErrorType}_${code}`);
|
|
121653
|
-
class src_client_KeetaNetAccountError extends src_client_KeetaNetErrorBase {
|
|
121654
|
-
constructor(code, message) {
|
|
121655
|
-
super(code, message, {
|
|
121656
|
-
type: client_AccountErrorType,
|
|
121657
|
-
codes: client_AccountErrorCodes
|
|
121658
|
-
});
|
|
121659
|
-
}
|
|
121660
|
-
}
|
|
121661
|
-
client_KeetaNetAccountError = src_client_KeetaNetAccountError;
|
|
121662
|
-
client_account_defineProperty(src_client_KeetaNetAccountError, "isInstance", client_checkableGenerator(client_KeetaNetAccountError));
|
|
121663
121916
|
;// ./src/lib/utils/ed2curve.ts
|
|
121664
121917
|
// https://raw.githubusercontent.com/jjavery/ed25519-to-x25519/main/src/ed2curve.js
|
|
121665
121918
|
|
|
@@ -122430,7 +122683,7 @@ class src_client_ExternalKeyPair extends client_KeyInterface {
|
|
|
122430
122683
|
return client_account_classPrivateFieldGet(client_functions, this).decrypt(...arguments);
|
|
122431
122684
|
}
|
|
122432
122685
|
get supportsEncryption() {
|
|
122433
|
-
return
|
|
122686
|
+
return client_account_classPrivateFieldGet(client_functions, this).supportsEncryption;
|
|
122434
122687
|
}
|
|
122435
122688
|
get keyType() {
|
|
122436
122689
|
return client_account_classPrivateFieldGet(client_keyType, this);
|
|
@@ -123121,10 +123374,8 @@ function client_derivePublicKeyStringFromPublicKey(key, keyType) {
|
|
|
123121
123374
|
}
|
|
123122
123375
|
|
|
123123
123376
|
/**
|
|
123124
|
-
*
|
|
123125
|
-
*
|
|
123126
|
-
*
|
|
123127
|
-
* @template T - The type of the key algorithm used for this account.
|
|
123377
|
+
* Statically validate that the KeyPairClassesByAlgorithm type has
|
|
123378
|
+
* every AccountKeyAlgorithm as a key
|
|
123128
123379
|
*/
|
|
123129
123380
|
var client_privateKeyPair = /*#__PURE__*/new WeakMap();
|
|
123130
123381
|
var client_publicKeyPair2 = /*#__PURE__*/new WeakMap();
|
|
@@ -123132,6 +123383,12 @@ var client_keyType4 = /*#__PURE__*/new WeakMap();
|
|
|
123132
123383
|
var client_keyPairHandlesHashing = /*#__PURE__*/new WeakMap();
|
|
123133
123384
|
var client_publicKeyString2 = /*#__PURE__*/new WeakMap();
|
|
123134
123385
|
var client_publicKeyAndTypeString = /*#__PURE__*/new WeakMap();
|
|
123386
|
+
/**
|
|
123387
|
+
* Account class, which is used to represent a key pair or an identifier
|
|
123388
|
+
* account (which have no private key) such as tokens.
|
|
123389
|
+
*
|
|
123390
|
+
* @template T - The type of the key algorithm used for this account.
|
|
123391
|
+
*/
|
|
123135
123392
|
class src_client_Account {
|
|
123136
123393
|
/**
|
|
123137
123394
|
* Construct an account from a public key string. The public key
|
|
@@ -123501,6 +123758,9 @@ class src_client_Account {
|
|
|
123501
123758
|
if (client_account_classPrivateFieldGet(client_privateKeyPair, this) === null) {
|
|
123502
123759
|
throw new Error('May not sign unless a private key is available');
|
|
123503
123760
|
}
|
|
123761
|
+
if (options.namespace !== undefined) {
|
|
123762
|
+
data = client_applyNamespace(options.namespace, data);
|
|
123763
|
+
}
|
|
123504
123764
|
if (!client_account_classPrivateFieldGet(client_keyPairHandlesHashing, this) && !options.raw) {
|
|
123505
123765
|
data = client_hash_Hash(client_account_Buffer.from(data));
|
|
123506
123766
|
}
|
|
@@ -123516,6 +123776,9 @@ class src_client_Account {
|
|
|
123516
123776
|
forCert: false,
|
|
123517
123777
|
...options
|
|
123518
123778
|
};
|
|
123779
|
+
if (options.namespace !== undefined) {
|
|
123780
|
+
data = client_applyNamespace(options.namespace, data);
|
|
123781
|
+
}
|
|
123519
123782
|
if (!client_account_classPrivateFieldGet(client_keyPairHandlesHashing, this) && !options.raw) {
|
|
123520
123783
|
data = client_hash_Hash(client_account_Buffer.from(data));
|
|
123521
123784
|
}
|
|
@@ -123658,10 +123921,12 @@ class src_client_Account {
|
|
|
123658
123921
|
* Determine if an account is an identifier
|
|
123659
123922
|
*/
|
|
123660
123923
|
isIdentifier() {
|
|
123661
|
-
|
|
123662
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
123663
|
-
return client_identifierKeyTypes.includes(this.keyType);
|
|
123924
|
+
return src_client_Account.isIdentifierKeyType(client_account_classPrivateFieldGet(client_keyType4, this));
|
|
123664
123925
|
}
|
|
123926
|
+
|
|
123927
|
+
/**
|
|
123928
|
+
* Determine if an account is a regular (non-identifier)
|
|
123929
|
+
*/
|
|
123665
123930
|
isAccount() {
|
|
123666
123931
|
return !this.isIdentifier();
|
|
123667
123932
|
}
|
|
@@ -123695,7 +123960,7 @@ class src_client_Account {
|
|
|
123695
123960
|
}
|
|
123696
123961
|
assertAccount() {
|
|
123697
123962
|
if (this.isIdentifier() !== false) {
|
|
123698
|
-
throw new
|
|
123963
|
+
throw new src_client_KeetaNetAccountError('ACCOUNT_NOT_ACCOUNT', 'Required Account but got Identifier');
|
|
123699
123964
|
}
|
|
123700
123965
|
|
|
123701
123966
|
// We need to assert this type because we are changing what the constructed type is
|
|
@@ -123704,7 +123969,7 @@ class src_client_Account {
|
|
|
123704
123969
|
}
|
|
123705
123970
|
assertIdentifier() {
|
|
123706
123971
|
if (this.isIdentifier() !== true) {
|
|
123707
|
-
throw new
|
|
123972
|
+
throw new src_client_KeetaNetAccountError('ACCOUNT_NOT_IDENTIFIER', `Required Identifier but got Account, ${this.keyType}`);
|
|
123708
123973
|
}
|
|
123709
123974
|
|
|
123710
123975
|
// We need to assert this type because we are changing what the constructed type is
|
|
@@ -123721,6 +123986,18 @@ client_Account = src_client_Account;
|
|
|
123721
123986
|
*/
|
|
123722
123987
|
client_lib_account_defineProperty(src_client_Account, "AccountKeyAlgorithm", client_AccountKeyAlgorithm);
|
|
123723
123988
|
client_lib_account_defineProperty(src_client_Account, "ExternalKeyPair", src_client_ExternalKeyPair);
|
|
123989
|
+
/**
|
|
123990
|
+
* Access to the underlying Key Pair classes for advanced use cases.
|
|
123991
|
+
*/
|
|
123992
|
+
client_lib_account_defineProperty(src_client_Account, "KeyPairs", {
|
|
123993
|
+
[client_AccountKeyAlgorithm.ECDSA_SECP256K1]: src_client_ECDSASECP256K1KeyPair,
|
|
123994
|
+
[client_AccountKeyAlgorithm.ECDSA_SECP256R1]: src_client_ECDSASECP256R1KeyPair,
|
|
123995
|
+
[client_AccountKeyAlgorithm.ED25519]: src_client_ED25519KeyPair,
|
|
123996
|
+
[client_AccountKeyAlgorithm.NETWORK]: src_client_IdentifierKeyPair,
|
|
123997
|
+
[client_AccountKeyAlgorithm.TOKEN]: src_client_IdentifierKeyPair,
|
|
123998
|
+
[client_AccountKeyAlgorithm.STORAGE]: src_client_IdentifierKeyPair,
|
|
123999
|
+
[client_AccountKeyAlgorithm.MULTISIG]: src_client_IdentifierKeyPair
|
|
124000
|
+
});
|
|
123724
124001
|
client_lib_account_defineProperty(src_client_Account, "isInstance", client_checkableGenerator(client_Account));
|
|
123725
124002
|
client_lib_account_defineProperty(src_client_Account, "Set", client_setGenerator(client_Account, function (account) {
|
|
123726
124003
|
const retval = account.publicKeyAndTypeString;
|
|
@@ -123896,34 +124173,53 @@ function client_addOrCombineRequirements(existing, addition, alwaysCombine) {
|
|
|
123896
124173
|
resp.push(addition);
|
|
123897
124174
|
return resp;
|
|
123898
124175
|
}
|
|
123899
|
-
function
|
|
123900
|
-
|
|
123901
|
-
|
|
123902
|
-
|
|
124176
|
+
function client_touchStateFields(state, toTouch) {
|
|
124177
|
+
let entityKey;
|
|
124178
|
+
let defaultValue;
|
|
124179
|
+
if (client_lib_account.isInstance(toTouch)) {
|
|
124180
|
+
entityKey = toTouch.publicKeyString.get();
|
|
124181
|
+
defaultValue = {
|
|
124182
|
+
type: 'ACCOUNT',
|
|
123903
124183
|
fields: {},
|
|
123904
|
-
account:
|
|
124184
|
+
account: toTouch
|
|
123905
124185
|
};
|
|
124186
|
+
} else if (toTouch.usingCertificate) {
|
|
124187
|
+
entityKey = `${toTouch.certificate.toString()}:${toTouch.certificateAccount.publicKeyString.get()}`;
|
|
124188
|
+
defaultValue = {
|
|
124189
|
+
type: 'CERTIFICATE',
|
|
124190
|
+
fields: {},
|
|
124191
|
+
certificateHash: toTouch.certificate,
|
|
124192
|
+
certificateAccount: toTouch.certificateAccount
|
|
124193
|
+
};
|
|
124194
|
+
} else {
|
|
124195
|
+
throw new Error('Invalid principal type in touchStateFields');
|
|
123906
124196
|
}
|
|
123907
|
-
|
|
123908
|
-
|
|
124197
|
+
let value = state.accounts[entityKey];
|
|
124198
|
+
if (value === undefined) {
|
|
124199
|
+
state.accounts[entityKey] = defaultValue;
|
|
124200
|
+
value = state.accounts[entityKey];
|
|
123909
124201
|
}
|
|
123910
|
-
|
|
123911
|
-
|
|
124202
|
+
return {
|
|
124203
|
+
value,
|
|
124204
|
+
entityKey
|
|
124205
|
+
};
|
|
124206
|
+
}
|
|
124207
|
+
function client_addPermission(state, addition) {
|
|
124208
|
+
const {
|
|
124209
|
+
value
|
|
124210
|
+
} = client_touchStateFields(state, addition.principal);
|
|
124211
|
+
if (value.fields.permissions === undefined) {
|
|
124212
|
+
value.fields.permissions = [];
|
|
123912
124213
|
}
|
|
123913
|
-
const existing =
|
|
123914
|
-
|
|
124214
|
+
const existing = value.fields.permissions || [];
|
|
124215
|
+
value.fields.permissions = client_addOrCombineRequirements(existing, addition);
|
|
123915
124216
|
}
|
|
123916
124217
|
function client_addPermissionRequirement(state, requirement) {
|
|
123917
|
-
var
|
|
123918
|
-
const
|
|
123919
|
-
|
|
123920
|
-
|
|
123921
|
-
|
|
123922
|
-
account: requirement.principal,
|
|
123923
|
-
fields: {}
|
|
123924
|
-
};
|
|
123925
|
-
}
|
|
123926
|
-
const alreadyAdded = (_state$accounts$princ = state.accounts[principalPubKey].fields.permissions) !== null && _state$accounts$princ !== void 0 ? _state$accounts$princ : [];
|
|
124218
|
+
var _principalFields$fiel, _principalFields$fiel2;
|
|
124219
|
+
const {
|
|
124220
|
+
value: principalFields
|
|
124221
|
+
} = client_touchStateFields(state, requirement.principal);
|
|
124222
|
+
const alreadyAdded = (_principalFields$fiel = principalFields.fields.permissions) !== null && _principalFields$fiel !== void 0 ? _principalFields$fiel : [];
|
|
123927
124223
|
const foundAddedMatch = alreadyAdded.find(function (_ref) {
|
|
123928
124224
|
let {
|
|
123929
124225
|
permissions
|
|
@@ -123936,6 +124232,7 @@ function client_addPermissionRequirement(state, requirement) {
|
|
|
123936
124232
|
if (foundAddedMatch !== undefined) {
|
|
123937
124233
|
return;
|
|
123938
124234
|
}
|
|
124235
|
+
const entityPubKey = requirement.entity.publicKeyString.get();
|
|
123939
124236
|
if (state.accounts[entityPubKey] !== undefined) {
|
|
123940
124237
|
const entityInfo = state.accounts[entityPubKey].fields.info;
|
|
123941
124238
|
if (entityInfo !== undefined && 'defaultPermission' in entityInfo) {
|
|
@@ -123947,13 +124244,14 @@ function client_addPermissionRequirement(state, requirement) {
|
|
|
123947
124244
|
}
|
|
123948
124245
|
}
|
|
123949
124246
|
}
|
|
123950
|
-
const existing = (
|
|
123951
|
-
|
|
124247
|
+
const existing = (_principalFields$fiel2 = principalFields.fields.permissionRequirements) !== null && _principalFields$fiel2 !== void 0 ? _principalFields$fiel2 : [];
|
|
124248
|
+
principalFields.fields.permissionRequirements = client_addOrCombineRequirements(existing, requirement, true);
|
|
123952
124249
|
}
|
|
123953
124250
|
function client_updateMinSignerSetLength(state, multisigAccount, count) {
|
|
123954
124251
|
const multisigPublicKey = multisigAccount.publicKeyString.get();
|
|
123955
124252
|
if (state.accounts[multisigPublicKey] === undefined) {
|
|
123956
124253
|
state.accounts[multisigPublicKey] = {
|
|
124254
|
+
type: 'ACCOUNT',
|
|
123957
124255
|
account: multisigAccount,
|
|
123958
124256
|
fields: {}
|
|
123959
124257
|
};
|
|
@@ -123977,6 +124275,7 @@ function client_modifyBalanceInState(balanceState) {
|
|
|
123977
124275
|
const tokenPubKey = token.publicKeyString.get();
|
|
123978
124276
|
if (state.accounts[accountPubKey] === undefined) {
|
|
123979
124277
|
state.accounts[accountPubKey] = {
|
|
124278
|
+
type: 'ACCOUNT',
|
|
123980
124279
|
account: client_lib_account.fromPublicKeyString(accountPubKey),
|
|
123981
124280
|
fields: {}
|
|
123982
124281
|
};
|
|
@@ -124042,6 +124341,7 @@ function client_updateAccountInfoInState(state, account, info) {
|
|
|
124042
124341
|
}
|
|
124043
124342
|
if (!state.accounts[accountPubKey]) {
|
|
124044
124343
|
state.accounts[accountPubKey] = {
|
|
124344
|
+
type: 'ACCOUNT',
|
|
124045
124345
|
account: account,
|
|
124046
124346
|
fields: {}
|
|
124047
124347
|
};
|
|
@@ -124199,6 +124499,7 @@ function client_computeEffectOfOperationCREATE_IDENTIFIER(state, block, operatio
|
|
|
124199
124499
|
for (const multisigSigner of operation.createArguments.signers) {
|
|
124200
124500
|
state.possibleNewAccounts.add(multisigSigner);
|
|
124201
124501
|
client_addPermission(state, {
|
|
124502
|
+
principalType: 'ACCOUNT',
|
|
124202
124503
|
principal: multisigSigner,
|
|
124203
124504
|
entity: operation.identifier,
|
|
124204
124505
|
method: src_client_Block.AdjustMethod.SET,
|
|
@@ -124207,6 +124508,7 @@ function client_computeEffectOfOperationCREATE_IDENTIFIER(state, block, operatio
|
|
|
124207
124508
|
}
|
|
124208
124509
|
} else {
|
|
124209
124510
|
client_addPermission(state, {
|
|
124511
|
+
principalType: 'ACCOUNT',
|
|
124210
124512
|
principal: block.account,
|
|
124211
124513
|
entity: operation.identifier,
|
|
124212
124514
|
method: src_client_Block.AdjustMethod.SET,
|
|
@@ -124223,17 +124525,41 @@ function client_computeEffectOfOperationSET_INFO(state, block, operation) {
|
|
|
124223
124525
|
});
|
|
124224
124526
|
}
|
|
124225
124527
|
function client_computeEffectOfOperationMODIFY_PERMISSIONS(state, block, operation) {
|
|
124226
|
-
|
|
124528
|
+
if (client_lib_account.isInstance(operation.principal)) {
|
|
124529
|
+
state.possibleNewAccounts.add(operation.principal);
|
|
124530
|
+
} else if (operation.principal.usingCertificate) {
|
|
124531
|
+
state.possibleNewAccounts.add(operation.principal.certificateAccount);
|
|
124532
|
+
} else {
|
|
124533
|
+
throw new Error('Invalid principal in MODIFY_PERMISSIONS operation');
|
|
124534
|
+
}
|
|
124227
124535
|
if (operation.target) {
|
|
124228
124536
|
state.possibleNewAccounts.add(operation.target);
|
|
124229
124537
|
}
|
|
124230
|
-
|
|
124231
|
-
principal: operation.principal,
|
|
124538
|
+
const shared = {
|
|
124232
124539
|
entity: block.account,
|
|
124233
124540
|
permissions: operation.permissions,
|
|
124234
124541
|
method: operation.method,
|
|
124235
124542
|
target: operation.target
|
|
124236
|
-
}
|
|
124543
|
+
};
|
|
124544
|
+
if (client_lib_account.isInstance(operation.principal)) {
|
|
124545
|
+
client_addPermission(state, {
|
|
124546
|
+
principalType: 'ACCOUNT',
|
|
124547
|
+
principal: operation.principal,
|
|
124548
|
+
...shared
|
|
124549
|
+
});
|
|
124550
|
+
} else if (operation.principal.usingCertificate) {
|
|
124551
|
+
client_addPermission(state, {
|
|
124552
|
+
principalType: 'CERTIFICATE',
|
|
124553
|
+
principal: {
|
|
124554
|
+
usingCertificate: true,
|
|
124555
|
+
certificate: operation.principal.certificateHash,
|
|
124556
|
+
certificateAccount: operation.principal.certificateAccount
|
|
124557
|
+
},
|
|
124558
|
+
...shared
|
|
124559
|
+
});
|
|
124560
|
+
} else {
|
|
124561
|
+
throw new Error('Invalid principal in MODIFY_PERMISSIONS operation');
|
|
124562
|
+
}
|
|
124237
124563
|
}
|
|
124238
124564
|
function client_computeEffectOfOperationTOKEN_ADMIN_SUPPLY(state, block, operation) {
|
|
124239
124565
|
var _state$accounts$token;
|
|
@@ -124314,14 +124640,19 @@ function client_computeEffectOfOperationMANAGE_CERTIFICATE(state, block, operati
|
|
|
124314
124640
|
const client_operationHandlers = {
|
|
124315
124641
|
[src_client_Block.OperationType.SEND]: {
|
|
124316
124642
|
effectGenerator: client_computeEffectOfOperationSEND,
|
|
124317
|
-
accountPermissionACL: (block, operation
|
|
124318
|
-
|
|
124319
|
-
|
|
124320
|
-
|
|
124643
|
+
accountPermissionACL: (block, operation) => {
|
|
124644
|
+
// Require both the sender and the recipient to have ['ACCESS'] on the token
|
|
124645
|
+
const baseEffect = [{
|
|
124646
|
+
principal: block.account,
|
|
124647
|
+
entity: operation.token
|
|
124648
|
+
}, {
|
|
124649
|
+
principal: operation.to,
|
|
124650
|
+
entity: operation.token
|
|
124651
|
+
}];
|
|
124321
124652
|
if (operation.to.keyType !== client_AccountKeyAlgorithm.STORAGE) {
|
|
124322
124653
|
return baseEffect;
|
|
124323
124654
|
}
|
|
124324
|
-
return [baseEffect,
|
|
124655
|
+
return [...baseEffect,
|
|
124325
124656
|
// Require that the token identifier was granted access by storage account for it to be able to hold
|
|
124326
124657
|
{
|
|
124327
124658
|
entity: operation.to,
|
|
@@ -124419,9 +124750,16 @@ const client_operationHandlers = {
|
|
|
124419
124750
|
delegateMethodNeeded = 'PERMISSION_DELEGATE_ADD';
|
|
124420
124751
|
break;
|
|
124421
124752
|
}
|
|
124753
|
+
let target;
|
|
124754
|
+
if (client_lib_account.isInstance(operation.principal)) {
|
|
124755
|
+
target = operation.principal;
|
|
124756
|
+
} else {
|
|
124757
|
+
// Currently, we do not have a way to specify a target for certificate principals, so we will not include a target in this case
|
|
124758
|
+
target = undefined;
|
|
124759
|
+
}
|
|
124422
124760
|
necessary.push({
|
|
124423
124761
|
permissions: new client_permissions_Permissions([delegateMethodNeeded]),
|
|
124424
|
-
target:
|
|
124762
|
+
target: target
|
|
124425
124763
|
});
|
|
124426
124764
|
return necessary;
|
|
124427
124765
|
}
|
|
@@ -124569,6 +124907,7 @@ function client_computeEffectOfBlocks(blocks, ledger) {
|
|
|
124569
124907
|
}
|
|
124570
124908
|
if (accumulatedEffects.accounts[blockAccountPubKey] === undefined) {
|
|
124571
124909
|
accumulatedEffects.accounts[blockAccountPubKey] = {
|
|
124910
|
+
type: 'ACCOUNT',
|
|
124572
124911
|
account: block.account,
|
|
124573
124912
|
fields: {}
|
|
124574
124913
|
};
|
|
@@ -124625,6 +124964,9 @@ function client_computeEffectOfBlocks(blocks, ledger) {
|
|
|
124625
124964
|
}
|
|
124626
124965
|
}
|
|
124627
124966
|
for (const effect of Object.values(accumulatedEffects.accounts)) {
|
|
124967
|
+
if (effect.type !== 'ACCOUNT') {
|
|
124968
|
+
continue;
|
|
124969
|
+
}
|
|
124628
124970
|
accumulatedEffects.touched.add(effect.account);
|
|
124629
124971
|
if (effect.fields.balance) {
|
|
124630
124972
|
let hasDebit = false;
|
|
@@ -126523,6 +126865,12 @@ class src_client_BaseVoteBuilder {
|
|
|
126523
126865
|
}
|
|
126524
126866
|
client_BaseVoteBuilder = src_client_BaseVoteBuilder;
|
|
126525
126867
|
function client_formatSingleFeeEntry(feeInput) {
|
|
126868
|
+
if (feeInput.amount === undefined) {
|
|
126869
|
+
throw new src_client_KeetaNetVoteError('VOTE_BUILDER_INVALID_FEE', 'Fee amount is required');
|
|
126870
|
+
}
|
|
126871
|
+
if (BigInt(feeInput.amount) < 0n) {
|
|
126872
|
+
throw new src_client_KeetaNetVoteError('VOTE_BUILDER_INVALID_FEE', 'Fee amount cannot be negative');
|
|
126873
|
+
}
|
|
126526
126874
|
const fee = {
|
|
126527
126875
|
amount: BigInt(feeInput.amount)
|
|
126528
126876
|
};
|
|
@@ -126611,6 +126959,8 @@ const src_client_Testing = {
|
|
|
126611
126959
|
feeExtensionSchema: client_feeExtensionSchema
|
|
126612
126960
|
};
|
|
126613
126961
|
;// ./src/lib/ledger/types.ts
|
|
126962
|
+
|
|
126963
|
+
|
|
126614
126964
|
/**
|
|
126615
126965
|
* Account info entry
|
|
126616
126966
|
*/
|
|
@@ -126641,19 +126991,33 @@ function client_isKeyPairAccountInfo(info) {
|
|
|
126641
126991
|
function client_isAccountInfoOfType(info, type) {
|
|
126642
126992
|
return info.account.isKeyType(type);
|
|
126643
126993
|
}
|
|
126994
|
+
const client_aclPrincipalType = (/* unused pure expression or super */ null && (['ACCOUNT', 'CERTIFICATE']));
|
|
126995
|
+
function client_isACLPrincipalType(type) {
|
|
126996
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
126997
|
+
return client_aclPrincipalType.includes(type);
|
|
126998
|
+
}
|
|
126999
|
+
function client_assertACLPrincipalType(type) {
|
|
127000
|
+
if (!client_isACLPrincipalType(type)) {
|
|
127001
|
+
throw new KeetaNetLedgerError('LEDGER_INVALID_ACL_ROW_TYPE', `Invalid ACL Row Type: ${type}`);
|
|
127002
|
+
}
|
|
127003
|
+
}
|
|
127004
|
+
function client_asACLPrincipalType(type) {
|
|
127005
|
+
client_assertACLPrincipalType(type);
|
|
127006
|
+
return type;
|
|
127007
|
+
}
|
|
126644
127008
|
|
|
126645
127009
|
/**
|
|
126646
127010
|
* Permissions types
|
|
126647
127011
|
*/
|
|
126648
127012
|
|
|
126649
127013
|
/**
|
|
126650
|
-
*
|
|
126651
|
-
* @expandType
|
|
127014
|
+
* A permission requirement for ledger effects
|
|
127015
|
+
* @expandType AccountACLRow
|
|
126652
127016
|
*/
|
|
126653
127017
|
|
|
126654
127018
|
/**
|
|
126655
127019
|
* Update an ACL for an account
|
|
126656
|
-
* @expandType
|
|
127020
|
+
* @expandType ACLRow
|
|
126657
127021
|
*/
|
|
126658
127022
|
|
|
126659
127023
|
/**
|
|
@@ -127974,6 +128338,7 @@ function client_lib_ledger_toPrimitive(t, r) { if ("object" != typeof t || !t) r
|
|
|
127974
128338
|
|
|
127975
128339
|
|
|
127976
128340
|
|
|
128341
|
+
|
|
127977
128342
|
/**
|
|
127978
128343
|
* Kind of ledger
|
|
127979
128344
|
*/
|
|
@@ -128003,6 +128368,10 @@ let client_LedgerKind = /*#__PURE__*/function (LedgerKind) {
|
|
|
128003
128368
|
* Options for "getVotesAfter"
|
|
128004
128369
|
*/
|
|
128005
128370
|
|
|
128371
|
+
/**
|
|
128372
|
+
* Filters for listing ACLs by entity
|
|
128373
|
+
*/
|
|
128374
|
+
|
|
128006
128375
|
/**
|
|
128007
128376
|
* Idempotent Key
|
|
128008
128377
|
*/
|
|
@@ -128174,6 +128543,14 @@ class client_LedgerAtomicInterface {
|
|
|
128174
128543
|
if (!quote.issuer.comparePublicKey(ledgerPubKey)) {
|
|
128175
128544
|
throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match issuer public key');
|
|
128176
128545
|
}
|
|
128546
|
+
if (quote.blocks.length !== blocks.length) {
|
|
128547
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match blocks length');
|
|
128548
|
+
}
|
|
128549
|
+
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
|
|
128550
|
+
if (!blocks[blockIndex].hash.compareHexString(quote.blocks[blockIndex])) {
|
|
128551
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_QUOTE_MISMATCH', 'Provided quote does not match blocks content');
|
|
128552
|
+
}
|
|
128553
|
+
}
|
|
128177
128554
|
}
|
|
128178
128555
|
|
|
128179
128556
|
/**
|
|
@@ -128201,6 +128578,7 @@ class client_LedgerAtomicInterface {
|
|
|
128201
128578
|
}
|
|
128202
128579
|
}
|
|
128203
128580
|
const requiredFees = new Map();
|
|
128581
|
+
const optionalFees = new Map();
|
|
128204
128582
|
for (const checkVote of otherVotes) {
|
|
128205
128583
|
if (checkVote.quote === true) {
|
|
128206
128584
|
throw new client_ledger_KeetaNetLedgerError('LEDGER_VOTE_WITH_QUOTE', 'Cannot request votes with quote as supporting votes');
|
|
@@ -128214,7 +128592,18 @@ class client_LedgerAtomicInterface {
|
|
|
128214
128592
|
seenVoteIssuers.add(checkVote.issuer);
|
|
128215
128593
|
seenVoteUIDs.add(checkVote.$id);
|
|
128216
128594
|
if (checkVote.fee !== undefined) {
|
|
128217
|
-
|
|
128595
|
+
const checkVoteFee = Array.isArray(checkVote.fee) ? checkVote.fee : [checkVote.fee];
|
|
128596
|
+
|
|
128597
|
+
// Check if user has the option to pay zero (any fee with amount === 0)
|
|
128598
|
+
// If a zero-amount option exists, fee block is optional; otherwise required
|
|
128599
|
+
const hasZeroFeeOption = checkVoteFee.some(fee => fee.amount === 0n);
|
|
128600
|
+
if (hasZeroFeeOption) {
|
|
128601
|
+
// At least one fee option is zero amount - fee block is optional, but if included should match one of the provided options
|
|
128602
|
+
optionalFees.set(checkVote.issuer, checkVote.fee);
|
|
128603
|
+
} else if (checkVoteFee.length > 0) {
|
|
128604
|
+
// All fee options require payment (no zero option) - fee block MUST be present and operation should match at least one fee option
|
|
128605
|
+
requiredFees.set(checkVote.issuer, checkVote.fee);
|
|
128606
|
+
}
|
|
128218
128607
|
}
|
|
128219
128608
|
|
|
128220
128609
|
/*
|
|
@@ -128242,25 +128631,43 @@ class client_LedgerAtomicInterface {
|
|
|
128242
128631
|
foundOurVote = true;
|
|
128243
128632
|
}
|
|
128244
128633
|
}
|
|
128245
|
-
|
|
128634
|
+
let finalRequiredFees = requiredFees;
|
|
128246
128635
|
/*
|
|
128247
128636
|
* We only care about fees if we are issuing a permanent vote,
|
|
128248
128637
|
* if we are issuing a temporary vote the fees will be checked
|
|
128249
128638
|
* when the permanent vote is requested
|
|
128250
128639
|
*/
|
|
128251
128640
|
if (outcome === 'permanent') {
|
|
128252
|
-
if (requiredFees.size > 0) {
|
|
128253
|
-
|
|
128254
|
-
|
|
128641
|
+
if (requiredFees.size > 0 || optionalFees.size > 0) {
|
|
128642
|
+
// If fees are required then a fee block should have been provided
|
|
128643
|
+
if (requiredFees.size > 0) {
|
|
128644
|
+
if (!hasFeeBlock) {
|
|
128645
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_MISSING_REQUIRED_FEE_BLOCK', 'Missing fee block but votes require it');
|
|
128646
|
+
}
|
|
128255
128647
|
}
|
|
128256
|
-
|
|
128257
|
-
|
|
128258
|
-
|
|
128648
|
+
|
|
128649
|
+
// We can only validate operations match if we have a fee block
|
|
128650
|
+
if (hasFeeBlock) {
|
|
128651
|
+
// Each vote requires exactly one fee payment, regardless of array size
|
|
128652
|
+
// Optional fees may or may not be included in the operations but if they are they should match
|
|
128653
|
+
if (optionalFees.size > 0) {
|
|
128654
|
+
if ((possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length) !== requiredFees.size && (possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length) !== requiredFees.size + optionalFees.size) {
|
|
128655
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees or required and optional fees');
|
|
128656
|
+
}
|
|
128657
|
+
// If user provided optional fees then we should validate they match
|
|
128658
|
+
if ((possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length) === requiredFees.size + optionalFees.size) {
|
|
128659
|
+
finalRequiredFees = new Map([...requiredFees, ...optionalFees]);
|
|
128660
|
+
}
|
|
128661
|
+
} else {
|
|
128662
|
+
if (requiredFees.size !== (possibleFeeBlock === null || possibleFeeBlock === void 0 ? void 0 : possibleFeeBlock.operations.length)) {
|
|
128663
|
+
throw new client_ledger_KeetaNetLedgerError('LEDGER_REQUIRED_FEE_MISMATCH', 'Fee Block Operations do not match required fees');
|
|
128664
|
+
}
|
|
128665
|
+
}
|
|
128259
128666
|
}
|
|
128260
128667
|
}
|
|
128261
128668
|
|
|
128262
128669
|
// Verify that at least one required fee option has been satisfied for each vote
|
|
128263
|
-
for (const [issuer, feeOrFees] of
|
|
128670
|
+
for (const [issuer, feeOrFees] of finalRequiredFees) {
|
|
128264
128671
|
// Handle both single fee and array of fees
|
|
128265
128672
|
const fees = Array.isArray(feeOrFees) ? feeOrFees : [feeOrFees];
|
|
128266
128673
|
|
|
@@ -128550,9 +128957,9 @@ class client_LedgerAtomicInterface {
|
|
|
128550
128957
|
const permissions = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).listACLsByPrincipal(transaction, principal, entityList);
|
|
128551
128958
|
return permissions;
|
|
128552
128959
|
}
|
|
128553
|
-
async listACLsByEntity(entity) {
|
|
128960
|
+
async listACLsByEntity(entity, options) {
|
|
128554
128961
|
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
128555
|
-
const permissions = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).listACLsByEntity(transaction, entity);
|
|
128962
|
+
const permissions = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).listACLsByEntity(transaction, entity, options);
|
|
128556
128963
|
return permissions;
|
|
128557
128964
|
}
|
|
128558
128965
|
async votingPower(rep) {
|
|
@@ -128591,6 +128998,10 @@ class client_LedgerAtomicInterface {
|
|
|
128591
128998
|
return retval;
|
|
128592
128999
|
}
|
|
128593
129000
|
async getAccountRep(account) {
|
|
129001
|
+
const acct = client_lib_account.toAccount(account);
|
|
129002
|
+
if (!client_canDelegate(acct.keyType)) {
|
|
129003
|
+
return null;
|
|
129004
|
+
}
|
|
128594
129005
|
const transaction = client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
128595
129006
|
const retval = await client_ledger_classPrivateFieldGet(client_ledger_storage, this).getAccountRep(transaction, account);
|
|
128596
129007
|
return retval;
|
|
@@ -128895,6 +129306,71 @@ async function client_listAccountInfo(accounts) {
|
|
|
128895
129306
|
await Promise.all(permissionPromises);
|
|
128896
129307
|
return accountInfo;
|
|
128897
129308
|
}
|
|
129309
|
+
async function client_fetchSatisfiedCertificateACLs(account, requirement) {
|
|
129310
|
+
const entityCertificateACLs = await this.listACLsByEntity(requirement.entity, {
|
|
129311
|
+
principalType: 'CERTIFICATE'
|
|
129312
|
+
});
|
|
129313
|
+
if (entityCertificateACLs.length === 0) {
|
|
129314
|
+
return null;
|
|
129315
|
+
}
|
|
129316
|
+
const entityACLsWithValuesResponse = await Promise.all(entityCertificateACLs.map(async acl => {
|
|
129317
|
+
if (acl.principalType !== 'CERTIFICATE') {
|
|
129318
|
+
throw new Error('Expected certificate ACL row');
|
|
129319
|
+
}
|
|
129320
|
+
const certificate = await this.getAccountCertificateByHash(acl.principal.certificateAccount, acl.principal.certificate);
|
|
129321
|
+
if (certificate === null) {
|
|
129322
|
+
return null;
|
|
129323
|
+
}
|
|
129324
|
+
return {
|
|
129325
|
+
acl,
|
|
129326
|
+
certificate
|
|
129327
|
+
};
|
|
129328
|
+
}));
|
|
129329
|
+
|
|
129330
|
+
// XXX:TODO does this need to be paginated
|
|
129331
|
+
const userCertificates = await this.getAccountCertificates(account);
|
|
129332
|
+
const matchedCertificateACLs = [];
|
|
129333
|
+
for (const aclWithCertificate of entityACLsWithValuesResponse) {
|
|
129334
|
+
if (!aclWithCertificate) {
|
|
129335
|
+
continue;
|
|
129336
|
+
}
|
|
129337
|
+
const {
|
|
129338
|
+
certificate: aclCertificate,
|
|
129339
|
+
acl
|
|
129340
|
+
} = aclWithCertificate;
|
|
129341
|
+
const issuerCertificate = new src_client_Certificate(aclCertificate.certificate, {
|
|
129342
|
+
isTrustedRoot: true
|
|
129343
|
+
});
|
|
129344
|
+
if (!issuerCertificate.checkValid()) {
|
|
129345
|
+
continue;
|
|
129346
|
+
}
|
|
129347
|
+
for (const userCertificate of userCertificates) {
|
|
129348
|
+
var _aclCertificate$inter, _aclCertificate$inter2, _userCertificate$inte, _userCertificate$inte2;
|
|
129349
|
+
if (!userCertificate.certificate.checkValid()) {
|
|
129350
|
+
continue;
|
|
129351
|
+
}
|
|
129352
|
+
const foundChain = userCertificate.certificate.verifyChain({
|
|
129353
|
+
root: new Set([issuerCertificate]),
|
|
129354
|
+
intermediate: new Set([...((_aclCertificate$inter = (_aclCertificate$inter2 = aclCertificate.intermediates) === null || _aclCertificate$inter2 === void 0 ? void 0 : _aclCertificate$inter2.getCertificates()) !== null && _aclCertificate$inter !== void 0 ? _aclCertificate$inter : []), ...((_userCertificate$inte = (_userCertificate$inte2 = userCertificate.intermediates) === null || _userCertificate$inte2 === void 0 ? void 0 : _userCertificate$inte2.getCertificates()) !== null && _userCertificate$inte !== void 0 ? _userCertificate$inte : [])])
|
|
129355
|
+
});
|
|
129356
|
+
if (foundChain === null) {
|
|
129357
|
+
continue;
|
|
129358
|
+
}
|
|
129359
|
+
let foundRootInChain = false;
|
|
129360
|
+
for (const certInChain of foundChain) {
|
|
129361
|
+
if (certInChain.hash().compareHexString(issuerCertificate.hash())) {
|
|
129362
|
+
foundRootInChain = true;
|
|
129363
|
+
break;
|
|
129364
|
+
}
|
|
129365
|
+
}
|
|
129366
|
+
if (!foundRootInChain) {
|
|
129367
|
+
throw new Error('Internal error: issuer certificate not found in verified chain');
|
|
129368
|
+
}
|
|
129369
|
+
matchedCertificateACLs.push(acl);
|
|
129370
|
+
}
|
|
129371
|
+
}
|
|
129372
|
+
return matchedCertificateACLs;
|
|
129373
|
+
}
|
|
128898
129374
|
async function client_checkSingleAccountPermissions(account, requirements, accountInfos) {
|
|
128899
129375
|
client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_assertTransaction).call(this);
|
|
128900
129376
|
|
|
@@ -128903,6 +129379,9 @@ async function client_checkSingleAccountPermissions(account, requirements, accou
|
|
|
128903
129379
|
const entityAccounts = new client_lib_account.Set(unfilteredEntity).toArray();
|
|
128904
129380
|
const gotPermissions = await this.listACLsByPrincipal(account, entityAccounts);
|
|
128905
129381
|
for (const requirement of requirements) {
|
|
129382
|
+
if (!requirement.permissions) {
|
|
129383
|
+
throw new Error('Unexpected null permissions in requirement');
|
|
129384
|
+
}
|
|
128906
129385
|
const reqEntityKey = requirement.entity.publicKeyString.get();
|
|
128907
129386
|
const foundACLRow = client_findPermissionMatch(requirement, gotPermissions);
|
|
128908
129387
|
const foundAccountInfo = accountInfos[reqEntityKey];
|
|
@@ -128914,10 +129393,19 @@ async function client_checkSingleAccountPermissions(account, requirements, accou
|
|
|
128914
129393
|
} else {
|
|
128915
129394
|
foundPermission = new client_permissions_Permissions();
|
|
128916
129395
|
}
|
|
128917
|
-
|
|
128918
|
-
|
|
129396
|
+
let hasPermissions = foundPermission.has(requirement.permissions);
|
|
129397
|
+
if (!hasPermissions && account.isAccount()) {
|
|
129398
|
+
const found = await client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, this, client_fetchSatisfiedCertificateACLs).call(this, account, requirement);
|
|
129399
|
+
if (found) {
|
|
129400
|
+
for (const row of found) {
|
|
129401
|
+
const certificateRowHasPermissions = row.permissions.has(requirement.permissions);
|
|
129402
|
+
if (certificateRowHasPermissions) {
|
|
129403
|
+
hasPermissions = true;
|
|
129404
|
+
break;
|
|
129405
|
+
}
|
|
129406
|
+
}
|
|
129407
|
+
}
|
|
128919
129408
|
}
|
|
128920
|
-
const hasPermissions = foundPermission.has(requirement.permissions);
|
|
128921
129409
|
if (!hasPermissions) {
|
|
128922
129410
|
var _requirement$target;
|
|
128923
129411
|
const accountPubKey = account.publicKeyString.get();
|
|
@@ -128935,19 +129423,22 @@ async function client_checkPermissionRequirements(effects) {
|
|
|
128935
129423
|
const needToGetAccountInfoFor = new client_lib_account.Set();
|
|
128936
129424
|
const allAccountsChanges = Object.values(effects);
|
|
128937
129425
|
const foundMultisigSignerLengths = [];
|
|
128938
|
-
for (const {
|
|
128939
|
-
|
|
128940
|
-
|
|
128941
|
-
|
|
128942
|
-
if (account.isMultisig()) {
|
|
129426
|
+
for (const accountChanges of allAccountsChanges) {
|
|
129427
|
+
const {
|
|
129428
|
+
fields
|
|
129429
|
+
} = accountChanges;
|
|
129430
|
+
if (accountChanges.type === 'ACCOUNT' && accountChanges.account.isMultisig()) {
|
|
128943
129431
|
if (fields.minSignerSetLength !== undefined) {
|
|
128944
|
-
needToGetAccountInfoFor.add(account);
|
|
128945
|
-
foundMultisigSignerLengths.push([account, fields.minSignerSetLength]);
|
|
129432
|
+
needToGetAccountInfoFor.add(accountChanges.account);
|
|
129433
|
+
foundMultisigSignerLengths.push([accountChanges.account, fields.minSignerSetLength]);
|
|
128946
129434
|
}
|
|
128947
129435
|
}
|
|
128948
129436
|
for (const singleRequirement of (_fields$permissionReq = fields.permissionRequirements) !== null && _fields$permissionReq !== void 0 ? _fields$permissionReq : []) {
|
|
128949
129437
|
var _fields$permissionReq;
|
|
128950
129438
|
const principal = singleRequirement.principal;
|
|
129439
|
+
if (!client_lib_account.isInstance(principal)) {
|
|
129440
|
+
throw new Error('Principal in permission requirement is not an account');
|
|
129441
|
+
}
|
|
128951
129442
|
const principalPubKey = principal.publicKeyString.get();
|
|
128952
129443
|
if (!requirementsByPrincipal[principalPubKey]) {
|
|
128953
129444
|
requirementsByPrincipal[principalPubKey] = [];
|
|
@@ -129091,6 +129582,9 @@ async function client_validateLedgerOutcome(blocks) {
|
|
|
129091
129582
|
}
|
|
129092
129583
|
for (const accountChanges of allAccountsChanges) {
|
|
129093
129584
|
var _fields$createRequest, _fields$permissions;
|
|
129585
|
+
if (accountChanges.type === 'CERTIFICATE') {
|
|
129586
|
+
continue;
|
|
129587
|
+
}
|
|
129094
129588
|
const {
|
|
129095
129589
|
account,
|
|
129096
129590
|
fields = {}
|
|
@@ -129109,6 +129603,10 @@ async function client_validateLedgerOutcome(blocks) {
|
|
|
129109
129603
|
*/
|
|
129110
129604
|
const addedPermissions = (_fields$permissions = fields.permissions) !== null && _fields$permissions !== void 0 ? _fields$permissions : [];
|
|
129111
129605
|
for (const newPerm of addedPermissions) {
|
|
129606
|
+
// We only care about permissions that include ownership, and non-accounts (ex: certificate principals) cannot be owners
|
|
129607
|
+
if (newPerm.principalType === 'CERTIFICATE') {
|
|
129608
|
+
continue;
|
|
129609
|
+
}
|
|
129112
129610
|
let method = 'ADD';
|
|
129113
129611
|
if (newPerm.permissions === null || !newPerm.permissions.has(['OWNER'])) {
|
|
129114
129612
|
method = 'REMOVE';
|
|
@@ -129301,7 +129799,13 @@ async function client_voteOrQuoteWithFees(blocks, type, quote, options) {
|
|
|
129301
129799
|
if (requireBlockTimestampCheck) {
|
|
129302
129800
|
var _quote$fee;
|
|
129303
129801
|
const fee = (_quote$fee = quote === null || quote === void 0 ? void 0 : quote.fee) !== null && _quote$fee !== void 0 ? _quote$fee : await this.getFee(blocks, effects);
|
|
129304
|
-
|
|
129802
|
+
// We add an explicit fee of 0 if one is not provided.
|
|
129803
|
+
// Since the quote identifier is in the fee data and needs to be parsed correctly.
|
|
129804
|
+
if (fee === null || Array.isArray(fee) && fee.length === 0) {
|
|
129805
|
+
builder.addFee({
|
|
129806
|
+
amount: 0n
|
|
129807
|
+
});
|
|
129808
|
+
} else {
|
|
129305
129809
|
builder.addFee(fee);
|
|
129306
129810
|
}
|
|
129307
129811
|
}
|
|
@@ -129728,7 +130232,7 @@ client_lib_ledger_defineProperty(src_client_Ledger, "isInstance", client_checkab
|
|
|
129728
130232
|
// EXTERNAL MODULE: ws (ignored)
|
|
129729
130233
|
var client_ws_ignored_ = __webpack_require__(4708);
|
|
129730
130234
|
;// ./src/version.ts
|
|
129731
|
-
const client_version = '0.
|
|
130235
|
+
const client_version = '0.18.0+g5417d9af948be899fcebb75694edb492ff971891';
|
|
129732
130236
|
/* harmony default export */ const client_src_version = ((/* unused pure expression or super */ null && (client_version)));
|
|
129733
130237
|
;// ./src/lib/p2p.ts
|
|
129734
130238
|
/* provided dependency */ var client_p2p_Buffer = __webpack_require__(8287)["Buffer"];
|
|
@@ -132362,6 +132866,7 @@ async function client_generateInitialVoteStaple(options) {
|
|
|
132362
132866
|
|
|
132363
132867
|
|
|
132364
132868
|
|
|
132869
|
+
|
|
132365
132870
|
/* harmony default export */ const client_src_lib = ({
|
|
132366
132871
|
/**
|
|
132367
132872
|
* The `Account` module provides functionality for managing key pairs
|
|
@@ -132381,11 +132886,12 @@ async function client_generateInitialVoteStaple(options) {
|
|
|
132381
132886
|
ASN1: client_utils_asn1_namespaceObject,
|
|
132382
132887
|
Bloom: client_bloom_namespaceObject,
|
|
132383
132888
|
Buffer: client_utils_buffer_namespaceObject,
|
|
132889
|
+
Certificate: client_utils_certificate_namespaceObject,
|
|
132890
|
+
Conversion: client_conversion_namespaceObject,
|
|
132891
|
+
DomainSeparation: client_domain_separation_namespaceObject,
|
|
132384
132892
|
Hash: client_hash_namespaceObject,
|
|
132385
132893
|
Helper: client_helper_namespaceObject,
|
|
132386
|
-
Initial: client_initial_namespaceObject
|
|
132387
|
-
Conversion: client_conversion_namespaceObject,
|
|
132388
|
-
Certificate: client_utils_certificate_namespaceObject
|
|
132894
|
+
Initial: client_initial_namespaceObject
|
|
132389
132895
|
}
|
|
132390
132896
|
});
|
|
132391
132897
|
;// ./src/client/builder.ts
|
|
@@ -132836,6 +133342,11 @@ class src_client_UserClientBuilder {
|
|
|
132836
133342
|
continue;
|
|
132837
133343
|
}
|
|
132838
133344
|
|
|
133345
|
+
// If fee options contains an amount of 0, skip this vote
|
|
133346
|
+
if (fees.some(fee => fee.amount === 0n)) {
|
|
133347
|
+
continue;
|
|
133348
|
+
}
|
|
133349
|
+
|
|
132839
133350
|
// Find fee with undefined token or matching baseToken
|
|
132840
133351
|
let selectedFee = fees.find(fee => {
|
|
132841
133352
|
if (fee.token === undefined || fee.token.comparePublicKey(baseToken)) {
|
|
@@ -133456,6 +133967,7 @@ function client_client_assertClassBrand(e, t, n) { if ("function" == typeof e ?
|
|
|
133456
133967
|
|
|
133457
133968
|
|
|
133458
133969
|
|
|
133970
|
+
|
|
133459
133971
|
|
|
133460
133972
|
|
|
133461
133973
|
/*
|
|
@@ -133711,6 +134223,15 @@ class src_client_Client {
|
|
|
133711
134223
|
return await this.transmit(blocks.blocks, options);
|
|
133712
134224
|
}
|
|
133713
134225
|
|
|
134226
|
+
/**
|
|
134227
|
+
* Check if the provided votes require a fee block. This is true if any vote has only non zero-amount options available.
|
|
134228
|
+
* If a vote has at least one zero-amount fee option, the user can satisfy the fee requirement without payment.
|
|
134229
|
+
* This is used to determine if we need to generate a fee block before transmitting the blocks.
|
|
134230
|
+
*
|
|
134231
|
+
* @param tempVotes
|
|
134232
|
+
* @returns boolean true if provided votes require a fee block
|
|
134233
|
+
*/
|
|
134234
|
+
|
|
133714
134235
|
/**
|
|
133715
134236
|
* Transmit a set of blocks to the network. This will request short
|
|
133716
134237
|
* votes and permanent votes for the blocks and then publish them to
|
|
@@ -133723,13 +134244,7 @@ class src_client_Client {
|
|
|
133723
134244
|
*/
|
|
133724
134245
|
async transmit(blocks, options) {
|
|
133725
134246
|
const tempVotes = await client_client_assertClassBrand(client_Client_brand, this, client_requestVotes).call(this, blocks, undefined, undefined, options === null || options === void 0 ? void 0 : options.quotes);
|
|
133726
|
-
|
|
133727
|
-
for (const vote of tempVotes) {
|
|
133728
|
-
if (vote.fee !== undefined) {
|
|
133729
|
-
requiresFee = true;
|
|
133730
|
-
}
|
|
133731
|
-
}
|
|
133732
|
-
if (requiresFee) {
|
|
134247
|
+
if (client_client_assertClassBrand(client_Client_brand, this, client_votesRequireFees).call(this, tempVotes)) {
|
|
133733
134248
|
if ((options === null || options === void 0 ? void 0 : options.generateFeeBlock) === undefined) {
|
|
133734
134249
|
throw new Error('Votes require fees but generateFeeBlock was not defined');
|
|
133735
134250
|
}
|
|
@@ -134758,16 +135273,9 @@ class src_client_Client {
|
|
|
134758
135273
|
tempVotes = [...tempVotes, ...newTempVotes];
|
|
134759
135274
|
}
|
|
134760
135275
|
const missingPermReps = client_client_classPrivateFieldGet(client_reps, this).filter(rep => !permReps.includes(rep));
|
|
134761
|
-
// If any of the temporary votes require a fee, we need to generate a fee block
|
|
134762
|
-
let requiresFee = false;
|
|
134763
|
-
for (const vote of tempVotes) {
|
|
134764
|
-
if (vote.fee !== undefined) {
|
|
134765
|
-
requiresFee = true;
|
|
134766
|
-
}
|
|
134767
|
-
}
|
|
134768
135276
|
|
|
134769
135277
|
// If we need a fee block and don't have any permanent votes, we need to generate a fee block
|
|
134770
|
-
if (
|
|
135278
|
+
if (client_client_assertClassBrand(client_Client_brand, this, client_votesRequireFees).call(this, tempVotes) && permVotes.length === 0) {
|
|
134771
135279
|
if ((options === null || options === void 0 ? void 0 : options.generateFeeBlock) === undefined) {
|
|
134772
135280
|
throw new Error('Votes require fees but generateFeeBlock was not defined');
|
|
134773
135281
|
}
|
|
@@ -135288,6 +135796,25 @@ function client_getBuilderRenderOptions(network) {
|
|
|
135288
135796
|
}
|
|
135289
135797
|
};
|
|
135290
135798
|
}
|
|
135799
|
+
function client_votesRequireFees(tempVotes) {
|
|
135800
|
+
let requiresFees = false;
|
|
135801
|
+
for (const vote of tempVotes) {
|
|
135802
|
+
if (vote.fee !== undefined) {
|
|
135803
|
+
const voteFee = Array.isArray(vote.fee) ? vote.fee : [vote.fee];
|
|
135804
|
+
|
|
135805
|
+
// Check if user has the option to pay zero (any fee with amount === 0)
|
|
135806
|
+
// If a zero-amount option exists, fee block is optional for this vote
|
|
135807
|
+
const hasZeroFeeOption = voteFee.some(fee => fee.amount === 0n);
|
|
135808
|
+
|
|
135809
|
+
// If no zero option exists (requires payment), fee block is required
|
|
135810
|
+
if (!hasZeroFeeOption) {
|
|
135811
|
+
requiresFees = true;
|
|
135812
|
+
break;
|
|
135813
|
+
}
|
|
135814
|
+
}
|
|
135815
|
+
}
|
|
135816
|
+
return requiresFees;
|
|
135817
|
+
}
|
|
135291
135818
|
function client_urlSeparatedAccounts(accounts) {
|
|
135292
135819
|
const pubKeys = accounts.map(account => client_lib_account.toPublicKeyString(account));
|
|
135293
135820
|
return pubKeys.join(',');
|
|
@@ -135360,12 +135887,31 @@ function client_parseAccountInfo(account, accountInfo) {
|
|
|
135360
135887
|
}
|
|
135361
135888
|
function client_parsePermissionEntries(entries) {
|
|
135362
135889
|
return entries.map(entry => {
|
|
135363
|
-
|
|
135364
|
-
principal: client_src_lib.Account.fromPublicKeyString(entry.principal),
|
|
135890
|
+
const shared = {
|
|
135365
135891
|
entity: client_src_lib.Account.fromPublicKeyString(entry.entity),
|
|
135366
135892
|
permissions: client_client_assertClassBrand(client_Client_brand, this, client_parseResponsePermissions).call(this, entry.permissions),
|
|
135367
135893
|
target: client_src_lib.Account.fromPublicKeyString(entry.target)
|
|
135368
135894
|
};
|
|
135895
|
+
if (entry.principalType === 'ACCOUNT') {
|
|
135896
|
+
return {
|
|
135897
|
+
principalType: 'ACCOUNT',
|
|
135898
|
+
principal: client_src_lib.Account.fromPublicKeyString(entry.principal),
|
|
135899
|
+
...shared
|
|
135900
|
+
};
|
|
135901
|
+
} else if (entry.principalType === 'CERTIFICATE') {
|
|
135902
|
+
return {
|
|
135903
|
+
principalType: 'CERTIFICATE',
|
|
135904
|
+
principal: {
|
|
135905
|
+
usingCertificate: true,
|
|
135906
|
+
certificate: new src_client_Certificate.Hash(entry.principal.certificate),
|
|
135907
|
+
certificateAccount: client_src_lib.Account.fromPublicKeyString(entry.principal.certificateAccount)
|
|
135908
|
+
},
|
|
135909
|
+
...shared
|
|
135910
|
+
};
|
|
135911
|
+
} else {
|
|
135912
|
+
client_assertNever(entry);
|
|
135913
|
+
}
|
|
135914
|
+
throw new Error('Unknown ACL Entry Type');
|
|
135369
135915
|
});
|
|
135370
135916
|
}
|
|
135371
135917
|
function client_mapCertificateWithBundleResult(input) {
|
|
@@ -135710,7 +136256,9 @@ class src_client_UserClient {
|
|
|
135710
136256
|
principals.push(operation.to);
|
|
135711
136257
|
break;
|
|
135712
136258
|
case client_OperationType.MODIFY_PERMISSIONS:
|
|
135713
|
-
|
|
136259
|
+
if (client_lib_account.isInstance(operation.principal)) {
|
|
136260
|
+
principals.push(operation.principal);
|
|
136261
|
+
}
|
|
135714
136262
|
break;
|
|
135715
136263
|
case client_OperationType.CREATE_IDENTIFIER:
|
|
135716
136264
|
principals.push(operation.identifier);
|