@keetanetwork/keetanet-client 0.16.2 → 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.js +509 -159
- package/client/index.js +511 -137
- 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.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/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 +3 -3
- 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.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/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/lib/block/index.d.ts +14 -2
- package/lib/block/operations.d.ts +40 -4
- 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/ledger/common.d.ts +7 -5
- package/lib/ledger/db_dynamodb.d.ts +2 -2
- package/lib/ledger/db_postgres.d.ts +3 -3
- package/lib/ledger/db_spanner.d.ts +3 -3
- package/lib/ledger/db_spanner_helper.d.ts +23 -3
- package/lib/ledger/db_sqlite.d.ts +3 -3
- package/lib/ledger/effects.d.ts +17 -9
- package/lib/ledger/index.d.ts +14 -5
- package/lib/ledger/types.d.ts +38 -14
- package/lib/log/target_gcp.js +19 -17
- 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 +4 -9
- package/lib/utils/external-keys/gcp-kms.js +52 -39
- package/lib/utils/external-keys/passkey-prf.d.ts +42 -1
- package/lib/utils/external-keys/passkey-prf.js +107 -13
- package/lib/vote.d.ts +7 -1
- package/npm-shrinkwrap.json +24 -24
- 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.js
CHANGED
|
@@ -58172,6 +58172,7 @@ const certificate_1 = __webpack_require__(5661);
|
|
|
58172
58172
|
const certificate_2 = __webpack_require__(5661);
|
|
58173
58173
|
const vote_1 = __webpack_require__(1130);
|
|
58174
58174
|
const ledger_1 = __webpack_require__(452);
|
|
58175
|
+
const never_1 = __webpack_require__(8692);
|
|
58175
58176
|
function isGetAccountStateAPIResponseFailure(object) {
|
|
58176
58177
|
if (typeof object !== 'object' || object === null) {
|
|
58177
58178
|
return (false);
|
|
@@ -59898,12 +59899,33 @@ async function _Client_apiRaw(rep, api, method, options = {}) {
|
|
|
59898
59899
|
});
|
|
59899
59900
|
}, _Client_parsePermissionEntries = function _Client_parsePermissionEntries(entries) {
|
|
59900
59901
|
return (entries.map(entry => {
|
|
59901
|
-
|
|
59902
|
-
principal: lib_1.default.Account.fromPublicKeyString(entry.principal),
|
|
59902
|
+
const shared = {
|
|
59903
59903
|
entity: lib_1.default.Account.fromPublicKeyString(entry.entity),
|
|
59904
59904
|
permissions: __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseResponsePermissions).call(this, entry.permissions),
|
|
59905
59905
|
target: lib_1.default.Account.fromPublicKeyString(entry.target)
|
|
59906
|
-
}
|
|
59906
|
+
};
|
|
59907
|
+
if (entry.principalType === 'ACCOUNT') {
|
|
59908
|
+
return ({
|
|
59909
|
+
principalType: 'ACCOUNT',
|
|
59910
|
+
principal: lib_1.default.Account.fromPublicKeyString(entry.principal),
|
|
59911
|
+
...shared
|
|
59912
|
+
});
|
|
59913
|
+
}
|
|
59914
|
+
else if (entry.principalType === 'CERTIFICATE') {
|
|
59915
|
+
return ({
|
|
59916
|
+
principalType: 'CERTIFICATE',
|
|
59917
|
+
principal: {
|
|
59918
|
+
usingCertificate: true,
|
|
59919
|
+
certificate: new certificate_1.Certificate.Hash(entry.principal.certificate),
|
|
59920
|
+
certificateAccount: lib_1.default.Account.fromPublicKeyString(entry.principal.certificateAccount)
|
|
59921
|
+
},
|
|
59922
|
+
...shared
|
|
59923
|
+
});
|
|
59924
|
+
}
|
|
59925
|
+
else {
|
|
59926
|
+
(0, never_1.assertNever)(entry);
|
|
59927
|
+
}
|
|
59928
|
+
throw (new Error('Unknown ACL Entry Type'));
|
|
59907
59929
|
}));
|
|
59908
59930
|
}, _Client_mapCertificateWithBundleResult = function _Client_mapCertificateWithBundleResult(input) {
|
|
59909
59931
|
let intermediates = null;
|
|
@@ -60209,7 +60231,9 @@ class UserClient {
|
|
|
60209
60231
|
principals.push(operation.to);
|
|
60210
60232
|
break;
|
|
60211
60233
|
case operations_1.OperationType.MODIFY_PERMISSIONS:
|
|
60212
|
-
|
|
60234
|
+
if (account_1.default.isInstance(operation.principal)) {
|
|
60235
|
+
principals.push(operation.principal);
|
|
60236
|
+
}
|
|
60213
60237
|
break;
|
|
60214
60238
|
case operations_1.OperationType.CREATE_IDENTIFIER:
|
|
60215
60239
|
principals.push(operation.identifier);
|
|
@@ -61167,7 +61191,7 @@ exports.baseValidationConfig = {
|
|
|
61167
61191
|
},
|
|
61168
61192
|
blockOperations: {
|
|
61169
61193
|
external: {
|
|
61170
|
-
maxLength:
|
|
61194
|
+
maxLength: 1024,
|
|
61171
61195
|
regex: /^[-_A-Za-z0-9+/= ]+$/,
|
|
61172
61196
|
canBeEmpty: true
|
|
61173
61197
|
},
|
|
@@ -64448,7 +64472,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
64448
64472
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64449
64473
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64450
64474
|
};
|
|
64451
|
-
var _BlockOperationSEND_instances, _BlockOperationSEND_to, _BlockOperationSEND_amount, _BlockOperationSEND_token, _BlockOperationSEND_computeToken, _BlockOperationRECEIVE_instances, _BlockOperationRECEIVE_amount, _BlockOperationRECEIVE_token, _BlockOperationRECEIVE_from, _BlockOperationRECEIVE_forward, _BlockOperationRECEIVE_exact, _BlockOperationRECEIVE_computeExact, _BlockOperationRECEIVE_computeForward, _BlockOperationRECEIVE_computeToken, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_instances, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_token, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_method, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_amount, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_computeToken, _BlockOperationSET_REP_to, _BlockOperationCREATE_IDENTIFIER_instances, _BlockOperationCREATE_IDENTIFIER_identifier, _BlockOperationCREATE_IDENTIFIER_createArguments, _BlockOperationCREATE_IDENTIFIER_computeIdentifier, _BlockOperationCREATE_IDENTIFIER_computeCreateArguments, _BlockOperationSET_INFO_instances, _BlockOperationSET_INFO_name, _BlockOperationSET_INFO_description, _BlockOperationSET_INFO_metadata, _BlockOperationSET_INFO_defaultPermission, _BlockOperationSET_INFO_validateNameDesc, _BlockOperationMODIFY_PERMISSIONS_instances, _BlockOperationMODIFY_PERMISSIONS_principal, _BlockOperationMODIFY_PERMISSIONS_target, _BlockOperationMODIFY_PERMISSIONS_method, _BlockOperationMODIFY_PERMISSIONS_permissions, _BlockOperationMODIFY_PERMISSIONS_computePermissions, _BlockOperationTOKEN_ADMIN_SUPPLY_instances, _BlockOperationTOKEN_ADMIN_SUPPLY_amount, _BlockOperationTOKEN_ADMIN_SUPPLY_method, _BlockOperationTOKEN_ADMIN_SUPPLY_computeSupplyMethod, _BlockOperationMANAGE_CERTIFICATE_instances, _BlockOperationMANAGE_CERTIFICATE_certificateOrHash, _BlockOperationMANAGE_CERTIFICATE_intermediateCertificates, _BlockOperationMANAGE_CERTIFICATE_method, _BlockOperationMANAGE_CERTIFICATE_asCertificate, _BlockOperationMANAGE_CERTIFICATE_asIntermediateCertificates, _BlockOperationMANAGE_CERTIFICATE_computeCertificateMethod;
|
|
64475
|
+
var _BlockOperationSEND_instances, _BlockOperationSEND_to, _BlockOperationSEND_amount, _BlockOperationSEND_token, _BlockOperationSEND_computeToken, _BlockOperationRECEIVE_instances, _BlockOperationRECEIVE_amount, _BlockOperationRECEIVE_token, _BlockOperationRECEIVE_from, _BlockOperationRECEIVE_forward, _BlockOperationRECEIVE_exact, _BlockOperationRECEIVE_computeExact, _BlockOperationRECEIVE_computeForward, _BlockOperationRECEIVE_computeToken, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_instances, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_token, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_method, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_amount, _BlockOperationTOKEN_ADMIN_MODIFY_BALANCE_computeToken, _BlockOperationSET_REP_to, _BlockOperationCREATE_IDENTIFIER_instances, _BlockOperationCREATE_IDENTIFIER_identifier, _BlockOperationCREATE_IDENTIFIER_createArguments, _BlockOperationCREATE_IDENTIFIER_computeIdentifier, _BlockOperationCREATE_IDENTIFIER_computeCreateArguments, _BlockOperationSET_INFO_instances, _BlockOperationSET_INFO_name, _BlockOperationSET_INFO_description, _BlockOperationSET_INFO_metadata, _BlockOperationSET_INFO_defaultPermission, _BlockOperationSET_INFO_validateNameDesc, _BlockOperationMODIFY_PERMISSIONS_instances, _BlockOperationMODIFY_PERMISSIONS_principal, _BlockOperationMODIFY_PERMISSIONS_target, _BlockOperationMODIFY_PERMISSIONS_method, _BlockOperationMODIFY_PERMISSIONS_permissions, _BlockOperationMODIFY_PERMISSIONS_computePrincipal, _BlockOperationMODIFY_PERMISSIONS_computePermissions, _BlockOperationTOKEN_ADMIN_SUPPLY_instances, _BlockOperationTOKEN_ADMIN_SUPPLY_amount, _BlockOperationTOKEN_ADMIN_SUPPLY_method, _BlockOperationTOKEN_ADMIN_SUPPLY_computeSupplyMethod, _BlockOperationMANAGE_CERTIFICATE_instances, _BlockOperationMANAGE_CERTIFICATE_certificateOrHash, _BlockOperationMANAGE_CERTIFICATE_intermediateCertificates, _BlockOperationMANAGE_CERTIFICATE_method, _BlockOperationMANAGE_CERTIFICATE_asCertificate, _BlockOperationMANAGE_CERTIFICATE_asIntermediateCertificates, _BlockOperationMANAGE_CERTIFICATE_computeCertificateMethod;
|
|
64452
64476
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
64453
64477
|
exports.Operation = exports.BlockOperationASN1Schema = exports.OperationType = void 0;
|
|
64454
64478
|
exports.createBlockOperation = createBlockOperation;
|
|
@@ -64506,6 +64530,9 @@ function operationTypeToNumber(str) {
|
|
|
64506
64530
|
}
|
|
64507
64531
|
return (type);
|
|
64508
64532
|
}
|
|
64533
|
+
const ModifyPermissionsPrincipalContextSpecificTagValues = {
|
|
64534
|
+
CERTIFICATE: 1
|
|
64535
|
+
};
|
|
64509
64536
|
function makeEncodeDecodePermission(emptyValue) {
|
|
64510
64537
|
return {
|
|
64511
64538
|
encode: (data) => {
|
|
@@ -64560,7 +64587,67 @@ const BlockOperationASN1SchemaBase = {
|
|
|
64560
64587
|
}
|
|
64561
64588
|
],
|
|
64562
64589
|
'MODIFY_PERMISSIONS': [
|
|
64563
|
-
{
|
|
64590
|
+
{
|
|
64591
|
+
name: 'principal',
|
|
64592
|
+
schema: {
|
|
64593
|
+
choice: [
|
|
64594
|
+
asn1_1.ValidateASN1.IsOctetString,
|
|
64595
|
+
{
|
|
64596
|
+
type: 'context',
|
|
64597
|
+
kind: 'explicit',
|
|
64598
|
+
value: ModifyPermissionsPrincipalContextSpecificTagValues.CERTIFICATE,
|
|
64599
|
+
contains: [
|
|
64600
|
+
/* Certificate Hash */
|
|
64601
|
+
asn1_1.ValidateASN1.IsOctetString,
|
|
64602
|
+
/* Certificate Issued To Account */
|
|
64603
|
+
asn1_1.ValidateASN1.IsOctetString
|
|
64604
|
+
]
|
|
64605
|
+
}
|
|
64606
|
+
]
|
|
64607
|
+
},
|
|
64608
|
+
encode(data) {
|
|
64609
|
+
if (account_1.default.isInstance(data)) {
|
|
64610
|
+
return (data.publicKeyAndType);
|
|
64611
|
+
}
|
|
64612
|
+
else if (data.usingCertificate) {
|
|
64613
|
+
return ({
|
|
64614
|
+
type: 'context',
|
|
64615
|
+
kind: 'explicit',
|
|
64616
|
+
value: ModifyPermissionsPrincipalContextSpecificTagValues.CERTIFICATE,
|
|
64617
|
+
contains: [
|
|
64618
|
+
data.certificateHash.getBuffer(),
|
|
64619
|
+
data.certificateAccount.publicKeyAndType
|
|
64620
|
+
]
|
|
64621
|
+
});
|
|
64622
|
+
}
|
|
64623
|
+
else {
|
|
64624
|
+
throw (new Error('Invalid principal type for MODIFY_PERMISSIONS operation'));
|
|
64625
|
+
}
|
|
64626
|
+
},
|
|
64627
|
+
decode(data) {
|
|
64628
|
+
if ((0, helper_1.isBuffer)(data)) {
|
|
64629
|
+
return (account_1.default.fromPublicKeyAndType(data));
|
|
64630
|
+
}
|
|
64631
|
+
else if (asn1_1.ASN1CheckUtilities.isASN1ContextTag(data, 'explicit')) {
|
|
64632
|
+
if (data.value === ModifyPermissionsPrincipalContextSpecificTagValues.CERTIFICATE) {
|
|
64633
|
+
if (!Array.isArray(data.contains) || data.contains.length !== 2) {
|
|
64634
|
+
throw (new Error('Invalid principal data for MODIFY_PERMISSIONS operation'));
|
|
64635
|
+
}
|
|
64636
|
+
const certificateHashData = data.contains[0];
|
|
64637
|
+
const certificateAccountData = data.contains[1];
|
|
64638
|
+
if (!(0, helper_1.isBuffer)(certificateHashData) || !(0, helper_1.isBuffer)(certificateAccountData)) {
|
|
64639
|
+
throw (new Error('Invalid certificate hash data for MODIFY_PERMISSIONS operation'));
|
|
64640
|
+
}
|
|
64641
|
+
return ({
|
|
64642
|
+
usingCertificate: true,
|
|
64643
|
+
certificateHash: new certificate_1.CertificateHash((0, helper_1.bufferToArrayBuffer)(certificateHashData)),
|
|
64644
|
+
certificateAccount: account_1.default.fromPublicKeyAndType(certificateAccountData)
|
|
64645
|
+
});
|
|
64646
|
+
}
|
|
64647
|
+
}
|
|
64648
|
+
throw (new Error('Invalid principal data for MODIFY_PERMISSIONS operation'));
|
|
64649
|
+
}
|
|
64650
|
+
},
|
|
64564
64651
|
{ name: 'method', schema: asn1_1.ValidateASN1.IsInteger },
|
|
64565
64652
|
{
|
|
64566
64653
|
name: 'permissions',
|
|
@@ -65258,7 +65345,7 @@ class BlockOperationMODIFY_PERMISSIONS extends BlockOperation {
|
|
|
65258
65345
|
if (input.type !== OperationType.MODIFY_PERMISSIONS) {
|
|
65259
65346
|
throw (new block_1.default('BLOCK_INVALID_TYPE', 'Invalid construction of BlockJSONOperationMODIFY_PERMISSIONS'));
|
|
65260
65347
|
}
|
|
65261
|
-
__classPrivateFieldSet(this, _BlockOperationMODIFY_PERMISSIONS_principal, this.
|
|
65348
|
+
__classPrivateFieldSet(this, _BlockOperationMODIFY_PERMISSIONS_principal, __classPrivateFieldGet(this, _BlockOperationMODIFY_PERMISSIONS_instances, "m", _BlockOperationMODIFY_PERMISSIONS_computePrincipal).call(this, input.principal), "f");
|
|
65262
65349
|
__classPrivateFieldSet(this, _BlockOperationMODIFY_PERMISSIONS_target, account_1.default.toAccount(input.target), "f");
|
|
65263
65350
|
__classPrivateFieldSet(this, _BlockOperationMODIFY_PERMISSIONS_method, (0, _1.toAdjustMethod)(input.method), "f");
|
|
65264
65351
|
__classPrivateFieldSet(this, _BlockOperationMODIFY_PERMISSIONS_permissions, __classPrivateFieldGet(this, _BlockOperationMODIFY_PERMISSIONS_instances, "m", _BlockOperationMODIFY_PERMISSIONS_computePermissions).call(this, input.permissions), "f");
|
|
@@ -65303,8 +65390,16 @@ class BlockOperationMODIFY_PERMISSIONS extends BlockOperation {
|
|
|
65303
65390
|
}
|
|
65304
65391
|
const { base } = this.permissions;
|
|
65305
65392
|
const baseFlagsString = `[${base.flags.join(',')}]`;
|
|
65306
|
-
if (
|
|
65307
|
-
|
|
65393
|
+
if (account_1.default.isInstance(this.principal)) {
|
|
65394
|
+
if (!base.checkAccountMatchesGroup('principal', this.principal)) {
|
|
65395
|
+
throw (new block_1.default('BLOCK_PERMISSIONS_INVALID_PRINCIPAL', `Incorrect principal for flags ${baseFlagsString}`));
|
|
65396
|
+
}
|
|
65397
|
+
}
|
|
65398
|
+
else {
|
|
65399
|
+
// If the principal is not an account, we only allow default permissions to be issued by a certificate principal
|
|
65400
|
+
if (!base.isValidForDefault) {
|
|
65401
|
+
throw (new block_1.default('BLOCK_PERMISSIONS_INVALID_DEFAULT', 'Invalid permissions, cannot use certificate principal with non-default permissions'));
|
|
65402
|
+
}
|
|
65308
65403
|
}
|
|
65309
65404
|
if (this.target && !base.checkAccountMatchesGroup('target', this.target)) {
|
|
65310
65405
|
throw (new block_1.default('BLOCK_PERMISSIONS_INVALID_TARGET', `Incorrect target for flags ${baseFlagsString}`));
|
|
@@ -65327,7 +65422,13 @@ class BlockOperationMODIFY_PERMISSIONS extends BlockOperation {
|
|
|
65327
65422
|
continue;
|
|
65328
65423
|
}
|
|
65329
65424
|
const { principal, target, method } = operation;
|
|
65330
|
-
|
|
65425
|
+
let principalKey;
|
|
65426
|
+
if (account_1.default.isInstance(principal)) {
|
|
65427
|
+
principalKey = principal.publicKeyString.get();
|
|
65428
|
+
}
|
|
65429
|
+
else {
|
|
65430
|
+
principalKey = `cert:${principal.certificateHash.get()}:${principal.certificateAccount.publicKeyString.get()}`;
|
|
65431
|
+
}
|
|
65331
65432
|
const targetKey = (target ?? block.account).publicKeyString.get();
|
|
65332
65433
|
if (!foundPrevious[principalKey]) {
|
|
65333
65434
|
foundPrevious[principalKey] = {};
|
|
@@ -65352,7 +65453,29 @@ class BlockOperationMODIFY_PERMISSIONS extends BlockOperation {
|
|
|
65352
65453
|
}));
|
|
65353
65454
|
}
|
|
65354
65455
|
}
|
|
65355
|
-
_BlockOperationMODIFY_PERMISSIONS_principal = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_target = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_method = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_permissions = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_instances = new WeakSet(),
|
|
65456
|
+
_BlockOperationMODIFY_PERMISSIONS_principal = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_target = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_method = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_permissions = new WeakMap(), _BlockOperationMODIFY_PERMISSIONS_instances = new WeakSet(), _BlockOperationMODIFY_PERMISSIONS_computePrincipal = function _BlockOperationMODIFY_PERMISSIONS_computePrincipal(principal) {
|
|
65457
|
+
if (typeof principal === 'string' || account_1.default.isInstance(principal)) {
|
|
65458
|
+
return (this.computeTo(principal));
|
|
65459
|
+
}
|
|
65460
|
+
else if (principal.usingCertificate) {
|
|
65461
|
+
const certificateAccount = account_1.default.toAccount(principal.certificateAccount);
|
|
65462
|
+
let certificateHash;
|
|
65463
|
+
if (certificate_1.CertificateHash.isInstance(principal.certificateHash)) {
|
|
65464
|
+
certificateHash = principal.certificateHash;
|
|
65465
|
+
}
|
|
65466
|
+
else {
|
|
65467
|
+
certificateHash = new certificate_1.CertificateHash(principal.certificateHash);
|
|
65468
|
+
}
|
|
65469
|
+
return ({
|
|
65470
|
+
usingCertificate: true,
|
|
65471
|
+
certificateHash,
|
|
65472
|
+
certificateAccount
|
|
65473
|
+
});
|
|
65474
|
+
}
|
|
65475
|
+
else {
|
|
65476
|
+
throw (new block_1.default('BLOCK_INVALID_PRINCIPAL', 'Invalid principal for MODIFY_PERMISSIONS'));
|
|
65477
|
+
}
|
|
65478
|
+
}, _BlockOperationMODIFY_PERMISSIONS_computePermissions = function _BlockOperationMODIFY_PERMISSIONS_computePermissions(permissions) {
|
|
65356
65479
|
if (!permissions) {
|
|
65357
65480
|
return (null);
|
|
65358
65481
|
}
|
|
@@ -65855,6 +65978,7 @@ exports.BlockErrorCodes = [
|
|
|
65855
65978
|
'INVALID_SIGNER',
|
|
65856
65979
|
'INVALID_TYPE',
|
|
65857
65980
|
'INVALID_VERSION',
|
|
65981
|
+
'INVALID_PRINCIPAL',
|
|
65858
65982
|
'NO_ADMIN_ON_TARGET',
|
|
65859
65983
|
'NO_DELEGATE_ADMIN',
|
|
65860
65984
|
'NO_DUPLICATE_CERTIFICATE_OPERATION',
|
|
@@ -66169,6 +66293,7 @@ exports.LedgerBaseErrorCodes = [
|
|
|
66169
66293
|
'INVALID_OWNER_COUNT',
|
|
66170
66294
|
'INVALID_BALANCE',
|
|
66171
66295
|
'INVALID_SET_REP',
|
|
66296
|
+
'INVALID_ACL_ROW_TYPE',
|
|
66172
66297
|
'OPERATION_NOT_SUPPORTED',
|
|
66173
66298
|
'NOT_EMPTY',
|
|
66174
66299
|
'PREVIOUS_ALREADY_USED',
|
|
@@ -66185,6 +66310,7 @@ exports.LedgerBaseErrorCodes = [
|
|
|
66185
66310
|
'DUPLICATE_VOTE_ISSUER_FOUND',
|
|
66186
66311
|
'OTHER',
|
|
66187
66312
|
'MISSING_BLOCKS',
|
|
66313
|
+
'CERTIFICATE_NOT_FOUND',
|
|
66188
66314
|
// Fee Errors
|
|
66189
66315
|
'FEE_AMOUNT_MISMATCH',
|
|
66190
66316
|
'FEE_TOKEN_MISMATCH',
|
|
@@ -66800,11 +66926,23 @@ const ledger_1 = __webpack_require__(452);
|
|
|
66800
66926
|
const helper_1 = __webpack_require__(3208);
|
|
66801
66927
|
const config_1 = __webpack_require__(1491);
|
|
66802
66928
|
const block_2 = __importDefault(__webpack_require__(7412));
|
|
66929
|
+
function areACLPrincipalEqual(a, b) {
|
|
66930
|
+
if (account_1.default.isInstance(a) || account_1.default.isInstance(b)) {
|
|
66931
|
+
if (!account_1.default.isInstance(a) || !account_1.default.isInstance(b)) {
|
|
66932
|
+
return (false);
|
|
66933
|
+
}
|
|
66934
|
+
return (a.comparePublicKey(b));
|
|
66935
|
+
}
|
|
66936
|
+
else {
|
|
66937
|
+
return (a.certificate.compareHexString(b.certificate) && a.certificateAccount.comparePublicKey(b.certificateAccount));
|
|
66938
|
+
}
|
|
66939
|
+
}
|
|
66803
66940
|
function findPermissionMatch(lookingFor, entries) {
|
|
66804
66941
|
const { principal, entity, target } = lookingFor;
|
|
66805
66942
|
let foundRow;
|
|
66806
66943
|
for (const entry of entries) {
|
|
66807
|
-
|
|
66944
|
+
// If principals do not match, we can skip
|
|
66945
|
+
if (!areACLPrincipalEqual(principal, entry.principal)) {
|
|
66808
66946
|
continue;
|
|
66809
66947
|
}
|
|
66810
66948
|
// We only care about permissions that have the same entity
|
|
@@ -66922,70 +67060,103 @@ async function computeLedgerEffect(options, effects, storageProvider, network, t
|
|
|
66922
67060
|
const resolved = await getAccountInfoPromises[accountPubKey];
|
|
66923
67061
|
return (resolved);
|
|
66924
67062
|
};
|
|
67063
|
+
const getCertificatePromises = {};
|
|
67064
|
+
const getCertificate = async (certificateHash, account) => {
|
|
67065
|
+
const promiseKey = `${certificateHash.toString()}-${account.publicKeyString.get()}`;
|
|
67066
|
+
if (getCertificatePromises[promiseKey] === undefined) {
|
|
67067
|
+
getCertificatePromises[promiseKey] = storageProvider.getAccountCertificateByHash(transaction, account, certificateHash);
|
|
67068
|
+
}
|
|
67069
|
+
return (await getCertificatePromises[promiseKey]);
|
|
67070
|
+
};
|
|
66925
67071
|
const getPermissionPromises = {};
|
|
66926
|
-
const getPermissions = async (
|
|
66927
|
-
|
|
67072
|
+
const getPermissions = async (principal, entityList) => {
|
|
67073
|
+
let promiseKey;
|
|
67074
|
+
if (account_1.default.isInstance(principal)) {
|
|
67075
|
+
promiseKey = `account-${principal.publicKeyString.get()}`;
|
|
67076
|
+
}
|
|
67077
|
+
else {
|
|
67078
|
+
promiseKey = `certificate-${principal.certificate.toString()}-${principal.certificateAccount.publicKeyString.get()}`;
|
|
67079
|
+
}
|
|
66928
67080
|
if (!entityList) {
|
|
66929
|
-
return (await getPermissionPromises[
|
|
67081
|
+
return (await getPermissionPromises[promiseKey]);
|
|
66930
67082
|
}
|
|
66931
|
-
if (getPermissionPromises[
|
|
67083
|
+
if (getPermissionPromises[promiseKey] !== undefined) {
|
|
66932
67084
|
throw (new Error('getPermissions() can only be called once per account'));
|
|
66933
67085
|
}
|
|
66934
|
-
getPermissionPromises[
|
|
66935
|
-
return (await getPermissionPromises[
|
|
67086
|
+
getPermissionPromises[promiseKey] = storageProvider.listACLsByPrincipal(transaction, principal, entityList);
|
|
67087
|
+
return (await getPermissionPromises[promiseKey]);
|
|
66936
67088
|
};
|
|
66937
67089
|
const prefetchPromises = [];
|
|
66938
|
-
for (const
|
|
66939
|
-
|
|
66940
|
-
|
|
66941
|
-
|
|
66942
|
-
|
|
66943
|
-
|
|
66944
|
-
|
|
66945
|
-
|
|
66946
|
-
|
|
66947
|
-
|
|
66948
|
-
toReadEntity.delete(permUpdate.entity);
|
|
66949
|
-
continue;
|
|
66950
|
-
}
|
|
66951
|
-
toReadEntity.add(permUpdate.entity);
|
|
67090
|
+
for (const effect of Object.values(effects)) {
|
|
67091
|
+
const fields = effect.fields;
|
|
67092
|
+
const toReadEntity = new account_1.default.Set();
|
|
67093
|
+
for (const permUpdate of fields.permissions ?? []) {
|
|
67094
|
+
if ((permUpdate.method === block_1.Block.AdjustMethod.ADD || permUpdate.method === block_1.Block.AdjustMethod.SET) && permUpdate.principalType === 'CERTIFICATE') {
|
|
67095
|
+
prefetchPromises.push(getCertificate(permUpdate.principal.certificate, permUpdate.principal.certificateAccount));
|
|
67096
|
+
}
|
|
67097
|
+
if (permUpdate.method === block_1.Block.AdjustMethod.SET || permUpdate.permissions === null) {
|
|
67098
|
+
toReadEntity.delete(permUpdate.entity);
|
|
67099
|
+
continue;
|
|
66952
67100
|
}
|
|
66953
|
-
|
|
67101
|
+
toReadEntity.add(permUpdate.entity);
|
|
66954
67102
|
}
|
|
66955
|
-
|
|
66956
|
-
|
|
66957
|
-
|
|
66958
|
-
if (isDelegating && computeWeights && getFinalNumericValues && canDelegate(account.keyType)) {
|
|
66959
|
-
requestedRep = true;
|
|
66960
|
-
prefetchPromises.push(getRep(account, getFinalNumericValues));
|
|
66961
|
-
prefetchPromises.push(getWeight(delegationField.delegateTo));
|
|
67103
|
+
let principal;
|
|
67104
|
+
if (effect.type === 'ACCOUNT') {
|
|
67105
|
+
principal = effect.account;
|
|
66962
67106
|
}
|
|
66963
|
-
|
|
66964
|
-
|
|
66965
|
-
|
|
66966
|
-
|
|
66967
|
-
|
|
66968
|
-
|
|
66969
|
-
|
|
66970
|
-
|
|
66971
|
-
|
|
66972
|
-
|
|
66973
|
-
|
|
66974
|
-
|
|
66975
|
-
|
|
66976
|
-
|
|
66977
|
-
|
|
66978
|
-
|
|
66979
|
-
|
|
66980
|
-
|
|
66981
|
-
|
|
66982
|
-
|
|
66983
|
-
|
|
66984
|
-
|
|
66985
|
-
|
|
66986
|
-
|
|
66987
|
-
|
|
66988
|
-
|
|
67107
|
+
else {
|
|
67108
|
+
principal = {
|
|
67109
|
+
usingCertificate: true,
|
|
67110
|
+
certificate: effect.certificateHash,
|
|
67111
|
+
certificateAccount: effect.certificateAccount
|
|
67112
|
+
};
|
|
67113
|
+
}
|
|
67114
|
+
// Only prefetch the permissions if we are computing the permissions
|
|
67115
|
+
if (computePermissions) {
|
|
67116
|
+
prefetchPromises.push(getPermissions(principal, toReadEntity.toArray()));
|
|
67117
|
+
}
|
|
67118
|
+
if (effect.type !== 'CERTIFICATE') {
|
|
67119
|
+
const { account } = effect;
|
|
67120
|
+
// Always fetch the supply from accountInfo if it's changing so we can validate the effect
|
|
67121
|
+
if ((fields.supply ?? []).length > 0 && (checkRangeConstraints || getFinalNumericValues)) {
|
|
67122
|
+
prefetchPromises.push(getAccountInfo(account));
|
|
67123
|
+
}
|
|
67124
|
+
const accountPubKey = account.publicKeyString.get();
|
|
67125
|
+
const delegationField = effects[accountPubKey]?.fields.delegation;
|
|
67126
|
+
const isDelegating = delegationField !== undefined;
|
|
67127
|
+
let requestedRep = false;
|
|
67128
|
+
if (isDelegating && computeWeights && getFinalNumericValues && canDelegate(account.keyType)) {
|
|
67129
|
+
requestedRep = true;
|
|
67130
|
+
prefetchPromises.push(getRep(account, getFinalNumericValues));
|
|
67131
|
+
prefetchPromises.push(getWeight(delegationField.delegateTo));
|
|
67132
|
+
}
|
|
67133
|
+
const rollingChanges = {};
|
|
67134
|
+
for (const tokenPubKey in fields.balance ?? {}) {
|
|
67135
|
+
for (const balanceUpdate of (fields.balance ?? {})[tokenPubKey]) {
|
|
67136
|
+
if (balanceUpdate.isReceive) {
|
|
67137
|
+
continue;
|
|
67138
|
+
}
|
|
67139
|
+
const { set, value } = balanceUpdate;
|
|
67140
|
+
const token = account_1.default.fromPublicKeyString(tokenPubKey).assertKeyType(account_1.AccountKeyAlgorithm.TOKEN);
|
|
67141
|
+
if (rollingChanges[tokenPubKey] === undefined) {
|
|
67142
|
+
rollingChanges[tokenPubKey] = 0n;
|
|
67143
|
+
}
|
|
67144
|
+
if (set) {
|
|
67145
|
+
prefetchPromises.push(getPreviousBalance(token, token));
|
|
67146
|
+
rollingChanges[tokenPubKey] = value;
|
|
67147
|
+
}
|
|
67148
|
+
else {
|
|
67149
|
+
rollingChanges[tokenPubKey] += value;
|
|
67150
|
+
}
|
|
67151
|
+
const isBaseToken = baseToken.comparePublicKey(tokenPubKey);
|
|
67152
|
+
const possibleNegative = rollingChanges[tokenPubKey] < 0n && checkRangeConstraints;
|
|
67153
|
+
if ((possibleNegative && checkRangeConstraints) || set || getFinalNumericValues || (isDelegating && computeWeights)) {
|
|
67154
|
+
prefetchPromises.push(getPreviousBalance(account, token));
|
|
67155
|
+
}
|
|
67156
|
+
if (computeWeights && isBaseToken && canDelegate(account.keyType) && !requestedRep) {
|
|
67157
|
+
requestedRep = true;
|
|
67158
|
+
prefetchPromises.push(getRep(account, getFinalNumericValues));
|
|
67159
|
+
}
|
|
66989
67160
|
}
|
|
66990
67161
|
}
|
|
66991
67162
|
}
|
|
@@ -67080,28 +67251,54 @@ async function computeLedgerEffect(options, effects, storageProvider, network, t
|
|
|
67080
67251
|
newEntry.change += change;
|
|
67081
67252
|
supplies[tokenPubKey] = newEntry;
|
|
67082
67253
|
};
|
|
67083
|
-
for (const
|
|
67084
|
-
const
|
|
67254
|
+
for (const effect of Object.values(effects)) {
|
|
67255
|
+
const fields = effect.fields;
|
|
67085
67256
|
for (const supplyChange of fields.supply ?? []) {
|
|
67086
|
-
if (!account.isToken()) {
|
|
67257
|
+
if (effect.type !== 'ACCOUNT' || !effect.account.isToken()) {
|
|
67087
67258
|
throw (new Error('Cannot modify supply of non-token account'));
|
|
67088
67259
|
}
|
|
67089
|
-
await modifySupply(account, supplyChange.value);
|
|
67090
|
-
}
|
|
67091
|
-
let permissionUpdates = [];
|
|
67092
|
-
if (computePermissions && fields.permissions) {
|
|
67093
|
-
permissionUpdates = fields.permissions;
|
|
67260
|
+
await modifySupply(effect.account, supplyChange.value);
|
|
67094
67261
|
}
|
|
67095
|
-
for (const permUpdate of
|
|
67096
|
-
|
|
67097
|
-
|
|
67262
|
+
for (const permUpdate of fields.permissions ?? []) {
|
|
67263
|
+
let principal;
|
|
67264
|
+
if (effect.type === 'ACCOUNT') {
|
|
67265
|
+
principal = effect.account;
|
|
67266
|
+
if (!account_1.default.isInstance(permUpdate.principal)) {
|
|
67267
|
+
throw (new Error('permUpdate.principal should be an account for ACCOUNT type effects'));
|
|
67268
|
+
}
|
|
67269
|
+
if (!permUpdate.principal.comparePublicKey(effect.account)) {
|
|
67270
|
+
throw (new Error('permUpdate.principal should not differ current account'));
|
|
67271
|
+
}
|
|
67272
|
+
}
|
|
67273
|
+
else {
|
|
67274
|
+
if (account_1.default.isInstance(permUpdate.principal)) {
|
|
67275
|
+
throw (new Error('permUpdate.principal should be a certificate for CERTIFICATE type effects'));
|
|
67276
|
+
}
|
|
67277
|
+
if (!permUpdate.principal.certificate.compareHexString(effect.certificateHash)) {
|
|
67278
|
+
throw (new Error('permUpdate.principal should not differ current certificate'));
|
|
67279
|
+
}
|
|
67280
|
+
principal = {
|
|
67281
|
+
usingCertificate: true,
|
|
67282
|
+
certificate: effect.certificateHash,
|
|
67283
|
+
certificateAccount: effect.certificateAccount
|
|
67284
|
+
};
|
|
67285
|
+
if (permUpdate.method === block_1.Block.AdjustMethod.ADD || permUpdate.method === block_1.Block.AdjustMethod.SET) {
|
|
67286
|
+
const certificate = await getCertificate(permUpdate.principal.certificate, permUpdate.principal.certificateAccount);
|
|
67287
|
+
if (!certificate) {
|
|
67288
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_CERTIFICATE_NOT_FOUND', `Certificate with hash ${permUpdate.principal.certificate.toString()} for account ${permUpdate.principal.certificateAccount.publicKeyString.get()} not found`));
|
|
67289
|
+
}
|
|
67290
|
+
}
|
|
67291
|
+
}
|
|
67292
|
+
// If not computing permissions, we only need to validate certificate existence
|
|
67293
|
+
if (!computePermissions) {
|
|
67294
|
+
continue;
|
|
67098
67295
|
}
|
|
67099
67296
|
if (permUpdate.method === block_1.Block.AdjustMethod.SET || permUpdate.permissions === null) {
|
|
67100
67297
|
permissions.push(permUpdate);
|
|
67101
67298
|
continue;
|
|
67102
67299
|
}
|
|
67103
67300
|
let newPermissions;
|
|
67104
|
-
const previousEntry = findPermissionMatch(permUpdate, await getPermissions(
|
|
67301
|
+
const previousEntry = findPermissionMatch(permUpdate, await getPermissions(principal));
|
|
67105
67302
|
const previousPermissions = previousEntry?.permissions ?? new permissions_1.Permissions();
|
|
67106
67303
|
switch (permUpdate.method) {
|
|
67107
67304
|
case block_1.Block.AdjustMethod.ADD:
|
|
@@ -67117,24 +67314,31 @@ async function computeLedgerEffect(options, effects, storageProvider, network, t
|
|
|
67117
67314
|
permissions: newPermissions
|
|
67118
67315
|
});
|
|
67119
67316
|
}
|
|
67120
|
-
|
|
67121
|
-
|
|
67122
|
-
if (
|
|
67123
|
-
|
|
67124
|
-
|
|
67125
|
-
|
|
67126
|
-
|
|
67127
|
-
await
|
|
67317
|
+
let isDelegating;
|
|
67318
|
+
let delegationField;
|
|
67319
|
+
if (effect.type === 'ACCOUNT') {
|
|
67320
|
+
delegationField = effects[effect.account.publicKeyString.get()]?.fields.delegation;
|
|
67321
|
+
isDelegating = delegationField !== undefined;
|
|
67322
|
+
if (isDelegating && delegationField && canDelegate(effect.account.keyType) && computeWeights) {
|
|
67323
|
+
const currentDelegation = await getRep(effect.account, getFinalNumericValues);
|
|
67324
|
+
const previousBalance = await getPreviousBalance(effect.account, baseToken);
|
|
67325
|
+
await modifyWeight(delegationField.delegateTo, previousBalance);
|
|
67326
|
+
if (currentDelegation) {
|
|
67327
|
+
await modifyWeight(currentDelegation, -1n * previousBalance);
|
|
67328
|
+
}
|
|
67128
67329
|
}
|
|
67129
67330
|
}
|
|
67130
67331
|
const receivable = {};
|
|
67131
67332
|
for (const tokenPubKey in fields.balance ?? {}) {
|
|
67132
67333
|
const tokenAcct = account_1.default.fromPublicKeyString(tokenPubKey).assertKeyType(account_1.AccountKeyAlgorithm.TOKEN);
|
|
67133
67334
|
for (const balanceUpdate of (fields.balance ?? {})[tokenPubKey]) {
|
|
67335
|
+
if (effect.type !== 'ACCOUNT') {
|
|
67336
|
+
throw (new Error('Only accounts can have balance changes'));
|
|
67337
|
+
}
|
|
67134
67338
|
const { isReceive, value, otherAccount } = balanceUpdate;
|
|
67135
67339
|
if (isReceive) {
|
|
67136
67340
|
const receiveFromPubKey = otherAccount.publicKeyString.get();
|
|
67137
|
-
const previousEntry = getBalanceEntry(account, tokenAcct);
|
|
67341
|
+
const previousEntry = getBalanceEntry(effect.account, tokenAcct);
|
|
67138
67342
|
if (previousEntry.receiveValidated === false) {
|
|
67139
67343
|
continue;
|
|
67140
67344
|
}
|
|
@@ -67152,16 +67356,16 @@ async function computeLedgerEffect(options, effects, storageProvider, network, t
|
|
|
67152
67356
|
else {
|
|
67153
67357
|
receiveValid = value <= receivableAmount;
|
|
67154
67358
|
}
|
|
67155
|
-
balances[
|
|
67359
|
+
balances[effect.account.publicKeyString.get()][tokenPubKey].receiveValidated = receiveValid;
|
|
67156
67360
|
continue;
|
|
67157
67361
|
}
|
|
67158
67362
|
let balanceChange;
|
|
67159
67363
|
if (balanceUpdate.set) {
|
|
67160
|
-
balanceChange = await modifyBalance(account, tokenAcct, value, true);
|
|
67364
|
+
balanceChange = await modifyBalance(effect.account, tokenAcct, value, true);
|
|
67161
67365
|
await modifyBalance(tokenAcct, tokenAcct, -1n * balanceChange, false);
|
|
67162
67366
|
}
|
|
67163
67367
|
else {
|
|
67164
|
-
balanceChange = await modifyBalance(account, tokenAcct, value, false);
|
|
67368
|
+
balanceChange = await modifyBalance(effect.account, tokenAcct, value, false);
|
|
67165
67369
|
}
|
|
67166
67370
|
if (balanceUpdate.receivable) {
|
|
67167
67371
|
const otherAccountPubKey = otherAccount.publicKeyString.get();
|
|
@@ -67173,12 +67377,15 @@ async function computeLedgerEffect(options, effects, storageProvider, network, t
|
|
|
67173
67377
|
receivable[otherAccountPubKey][tokenPubKey] += balanceChange;
|
|
67174
67378
|
}
|
|
67175
67379
|
const isBaseToken = baseToken.comparePublicKey(tokenAcct);
|
|
67176
|
-
if (isBaseToken && canDelegate(account.keyType) && computeWeights) {
|
|
67380
|
+
if (isBaseToken && canDelegate(effect.account.keyType) && computeWeights) {
|
|
67177
67381
|
if (isDelegating) {
|
|
67382
|
+
if (!delegationField) {
|
|
67383
|
+
throw (new Error('delegationField should be defined if isDelegating is true'));
|
|
67384
|
+
}
|
|
67178
67385
|
await modifyWeight(delegationField.delegateTo, balanceChange);
|
|
67179
67386
|
}
|
|
67180
67387
|
else {
|
|
67181
|
-
const currentRep = await getRep(account);
|
|
67388
|
+
const currentRep = await getRep(effect.account);
|
|
67182
67389
|
if (currentRep) {
|
|
67183
67390
|
await modifyWeight(currentRep, balanceChange);
|
|
67184
67391
|
}
|
|
@@ -67610,33 +67817,47 @@ function addOrCombineRequirements(existing, addition, alwaysCombine) {
|
|
|
67610
67817
|
resp.push(addition);
|
|
67611
67818
|
return (resp);
|
|
67612
67819
|
}
|
|
67613
|
-
function
|
|
67614
|
-
|
|
67615
|
-
|
|
67616
|
-
|
|
67820
|
+
function touchStateFields(state, toTouch) {
|
|
67821
|
+
let entityKey;
|
|
67822
|
+
let defaultValue;
|
|
67823
|
+
if (account_1.default.isInstance(toTouch)) {
|
|
67824
|
+
entityKey = toTouch.publicKeyString.get();
|
|
67825
|
+
defaultValue = {
|
|
67826
|
+
type: 'ACCOUNT',
|
|
67617
67827
|
fields: {},
|
|
67618
|
-
account:
|
|
67828
|
+
account: toTouch
|
|
67619
67829
|
};
|
|
67620
67830
|
}
|
|
67621
|
-
if (
|
|
67622
|
-
|
|
67831
|
+
else if (toTouch.usingCertificate) {
|
|
67832
|
+
entityKey = `${toTouch.certificate.toString()}:${toTouch.certificateAccount.publicKeyString.get()}`;
|
|
67833
|
+
defaultValue = {
|
|
67834
|
+
type: 'CERTIFICATE',
|
|
67835
|
+
fields: {},
|
|
67836
|
+
certificateHash: toTouch.certificate,
|
|
67837
|
+
certificateAccount: toTouch.certificateAccount
|
|
67838
|
+
};
|
|
67623
67839
|
}
|
|
67624
|
-
|
|
67625
|
-
|
|
67840
|
+
else {
|
|
67841
|
+
throw (new Error('Invalid principal type in touchStateFields'));
|
|
67626
67842
|
}
|
|
67627
|
-
|
|
67628
|
-
|
|
67843
|
+
let value = state.accounts[entityKey];
|
|
67844
|
+
if (value === undefined) {
|
|
67845
|
+
state.accounts[entityKey] = defaultValue;
|
|
67846
|
+
value = state.accounts[entityKey];
|
|
67847
|
+
}
|
|
67848
|
+
return ({ value, entityKey });
|
|
67629
67849
|
}
|
|
67630
|
-
function
|
|
67631
|
-
const
|
|
67632
|
-
|
|
67633
|
-
|
|
67634
|
-
state.accounts[principalPubKey] = {
|
|
67635
|
-
account: requirement.principal,
|
|
67636
|
-
fields: {}
|
|
67637
|
-
};
|
|
67850
|
+
function addPermission(state, addition) {
|
|
67851
|
+
const { value } = touchStateFields(state, addition.principal);
|
|
67852
|
+
if (value.fields.permissions === undefined) {
|
|
67853
|
+
value.fields.permissions = [];
|
|
67638
67854
|
}
|
|
67639
|
-
const
|
|
67855
|
+
const existing = value.fields.permissions || [];
|
|
67856
|
+
value.fields.permissions = addOrCombineRequirements(existing, addition);
|
|
67857
|
+
}
|
|
67858
|
+
function addPermissionRequirement(state, requirement) {
|
|
67859
|
+
const { value: principalFields } = touchStateFields(state, requirement.principal);
|
|
67860
|
+
const alreadyAdded = principalFields.fields.permissions ?? [];
|
|
67640
67861
|
const foundAddedMatch = alreadyAdded.find(function ({ permissions }) {
|
|
67641
67862
|
if (requirement.permissions === null) {
|
|
67642
67863
|
return (true);
|
|
@@ -67646,6 +67867,7 @@ function addPermissionRequirement(state, requirement) {
|
|
|
67646
67867
|
if (foundAddedMatch !== undefined) {
|
|
67647
67868
|
return;
|
|
67648
67869
|
}
|
|
67870
|
+
const entityPubKey = requirement.entity.publicKeyString.get();
|
|
67649
67871
|
if (state.accounts[entityPubKey] !== undefined) {
|
|
67650
67872
|
const entityInfo = state.accounts[entityPubKey].fields.info;
|
|
67651
67873
|
if (entityInfo !== undefined && 'defaultPermission' in entityInfo) {
|
|
@@ -67657,13 +67879,14 @@ function addPermissionRequirement(state, requirement) {
|
|
|
67657
67879
|
}
|
|
67658
67880
|
}
|
|
67659
67881
|
}
|
|
67660
|
-
const existing =
|
|
67661
|
-
|
|
67882
|
+
const existing = principalFields.fields.permissionRequirements ?? [];
|
|
67883
|
+
principalFields.fields.permissionRequirements = addOrCombineRequirements(existing, requirement, true);
|
|
67662
67884
|
}
|
|
67663
67885
|
function updateMinSignerSetLength(state, multisigAccount, count) {
|
|
67664
67886
|
const multisigPublicKey = multisigAccount.publicKeyString.get();
|
|
67665
67887
|
if (state.accounts[multisigPublicKey] === undefined) {
|
|
67666
67888
|
state.accounts[multisigPublicKey] = {
|
|
67889
|
+
type: 'ACCOUNT',
|
|
67667
67890
|
account: multisigAccount,
|
|
67668
67891
|
fields: {}
|
|
67669
67892
|
};
|
|
@@ -67679,6 +67902,7 @@ function modifyBalanceInState(balanceState) {
|
|
|
67679
67902
|
const tokenPubKey = token.publicKeyString.get();
|
|
67680
67903
|
if (state.accounts[accountPubKey] === undefined) {
|
|
67681
67904
|
state.accounts[accountPubKey] = {
|
|
67905
|
+
type: 'ACCOUNT',
|
|
67682
67906
|
account: account_1.default.fromPublicKeyString(accountPubKey),
|
|
67683
67907
|
fields: {}
|
|
67684
67908
|
};
|
|
@@ -67745,6 +67969,7 @@ function updateAccountInfoInState(state, account, info) {
|
|
|
67745
67969
|
}
|
|
67746
67970
|
if (!state.accounts[accountPubKey]) {
|
|
67747
67971
|
state.accounts[accountPubKey] = {
|
|
67972
|
+
type: 'ACCOUNT',
|
|
67748
67973
|
account: account,
|
|
67749
67974
|
fields: {}
|
|
67750
67975
|
};
|
|
@@ -67892,6 +68117,7 @@ function computeEffectOfOperationCREATE_IDENTIFIER(state, block, operation, cont
|
|
|
67892
68117
|
for (const multisigSigner of operation.createArguments.signers) {
|
|
67893
68118
|
state.possibleNewAccounts.add(multisigSigner);
|
|
67894
68119
|
addPermission(state, {
|
|
68120
|
+
principalType: 'ACCOUNT',
|
|
67895
68121
|
principal: multisigSigner,
|
|
67896
68122
|
entity: operation.identifier,
|
|
67897
68123
|
method: block_1.Block.AdjustMethod.SET,
|
|
@@ -67901,6 +68127,7 @@ function computeEffectOfOperationCREATE_IDENTIFIER(state, block, operation, cont
|
|
|
67901
68127
|
}
|
|
67902
68128
|
else {
|
|
67903
68129
|
addPermission(state, {
|
|
68130
|
+
principalType: 'ACCOUNT',
|
|
67904
68131
|
principal: block.account,
|
|
67905
68132
|
entity: operation.identifier,
|
|
67906
68133
|
method: block_1.Block.AdjustMethod.SET,
|
|
@@ -67917,17 +68144,45 @@ function computeEffectOfOperationSET_INFO(state, block, operation) {
|
|
|
67917
68144
|
});
|
|
67918
68145
|
}
|
|
67919
68146
|
function computeEffectOfOperationMODIFY_PERMISSIONS(state, block, operation) {
|
|
67920
|
-
|
|
68147
|
+
if (account_1.default.isInstance(operation.principal)) {
|
|
68148
|
+
state.possibleNewAccounts.add(operation.principal);
|
|
68149
|
+
}
|
|
68150
|
+
else if (operation.principal.usingCertificate) {
|
|
68151
|
+
state.possibleNewAccounts.add(operation.principal.certificateAccount);
|
|
68152
|
+
}
|
|
68153
|
+
else {
|
|
68154
|
+
throw (new Error('Invalid principal in MODIFY_PERMISSIONS operation'));
|
|
68155
|
+
}
|
|
67921
68156
|
if (operation.target) {
|
|
67922
68157
|
state.possibleNewAccounts.add(operation.target);
|
|
67923
68158
|
}
|
|
67924
|
-
|
|
67925
|
-
principal: operation.principal,
|
|
68159
|
+
const shared = {
|
|
67926
68160
|
entity: block.account,
|
|
67927
68161
|
permissions: operation.permissions,
|
|
67928
68162
|
method: operation.method,
|
|
67929
68163
|
target: operation.target
|
|
67930
|
-
}
|
|
68164
|
+
};
|
|
68165
|
+
if (account_1.default.isInstance(operation.principal)) {
|
|
68166
|
+
addPermission(state, {
|
|
68167
|
+
principalType: 'ACCOUNT',
|
|
68168
|
+
principal: operation.principal,
|
|
68169
|
+
...shared
|
|
68170
|
+
});
|
|
68171
|
+
}
|
|
68172
|
+
else if (operation.principal.usingCertificate) {
|
|
68173
|
+
addPermission(state, {
|
|
68174
|
+
principalType: 'CERTIFICATE',
|
|
68175
|
+
principal: {
|
|
68176
|
+
usingCertificate: true,
|
|
68177
|
+
certificate: operation.principal.certificateHash,
|
|
68178
|
+
certificateAccount: operation.principal.certificateAccount
|
|
68179
|
+
},
|
|
68180
|
+
...shared
|
|
68181
|
+
});
|
|
68182
|
+
}
|
|
68183
|
+
else {
|
|
68184
|
+
throw (new Error('Invalid principal in MODIFY_PERMISSIONS operation'));
|
|
68185
|
+
}
|
|
67931
68186
|
}
|
|
67932
68187
|
function computeEffectOfOperationTOKEN_ADMIN_SUPPLY(state, block, operation) {
|
|
67933
68188
|
const tokenPubKey = block.account.publicKeyString.get();
|
|
@@ -68007,15 +68262,23 @@ function computeEffectOfOperationMANAGE_CERTIFICATE(state, block, operation, con
|
|
|
68007
68262
|
const operationHandlers = {
|
|
68008
68263
|
[block_1.Block.OperationType.SEND]: {
|
|
68009
68264
|
effectGenerator: computeEffectOfOperationSEND,
|
|
68010
|
-
accountPermissionACL: (block, operation
|
|
68011
|
-
|
|
68012
|
-
|
|
68013
|
-
|
|
68265
|
+
accountPermissionACL: (block, operation) => {
|
|
68266
|
+
// Require both the sender and the recipient to have ['ACCESS'] on the token
|
|
68267
|
+
const baseEffect = [
|
|
68268
|
+
{
|
|
68269
|
+
principal: block.account,
|
|
68270
|
+
entity: operation.token
|
|
68271
|
+
},
|
|
68272
|
+
{
|
|
68273
|
+
principal: operation.to,
|
|
68274
|
+
entity: operation.token
|
|
68275
|
+
}
|
|
68276
|
+
];
|
|
68014
68277
|
if (operation.to.keyType !== account_1.AccountKeyAlgorithm.STORAGE) {
|
|
68015
68278
|
return (baseEffect);
|
|
68016
68279
|
}
|
|
68017
68280
|
return ([
|
|
68018
|
-
baseEffect,
|
|
68281
|
+
...baseEffect,
|
|
68019
68282
|
// Require that the token identifier was granted access by storage account for it to be able to hold
|
|
68020
68283
|
{
|
|
68021
68284
|
entity: operation.to,
|
|
@@ -68109,9 +68372,17 @@ const operationHandlers = {
|
|
|
68109
68372
|
delegateMethodNeeded = 'PERMISSION_DELEGATE_ADD';
|
|
68110
68373
|
break;
|
|
68111
68374
|
}
|
|
68375
|
+
let target;
|
|
68376
|
+
if (account_1.default.isInstance(operation.principal)) {
|
|
68377
|
+
target = operation.principal;
|
|
68378
|
+
}
|
|
68379
|
+
else {
|
|
68380
|
+
// Currently, we do not have a way to specify a target for certificate principals, so we will not include a target in this case
|
|
68381
|
+
target = undefined;
|
|
68382
|
+
}
|
|
68112
68383
|
necessary.push({
|
|
68113
68384
|
permissions: new permissions_1.Permissions([delegateMethodNeeded]),
|
|
68114
|
-
target:
|
|
68385
|
+
target: target
|
|
68115
68386
|
});
|
|
68116
68387
|
return (necessary);
|
|
68117
68388
|
}
|
|
@@ -68250,6 +68521,7 @@ function computeEffectOfBlocks(blocks, ledger) {
|
|
|
68250
68521
|
}
|
|
68251
68522
|
if (accumulatedEffects.accounts[blockAccountPubKey] === undefined) {
|
|
68252
68523
|
accumulatedEffects.accounts[blockAccountPubKey] = {
|
|
68524
|
+
type: 'ACCOUNT',
|
|
68253
68525
|
account: block.account,
|
|
68254
68526
|
fields: {}
|
|
68255
68527
|
};
|
|
@@ -68306,6 +68578,9 @@ function computeEffectOfBlocks(blocks, ledger) {
|
|
|
68306
68578
|
}
|
|
68307
68579
|
}
|
|
68308
68580
|
for (const effect of Object.values(accumulatedEffects.accounts)) {
|
|
68581
|
+
if (effect.type !== 'ACCOUNT') {
|
|
68582
|
+
continue;
|
|
68583
|
+
}
|
|
68309
68584
|
accumulatedEffects.touched.add(effect.account);
|
|
68310
68585
|
if (effect.fields.balance) {
|
|
68311
68586
|
let hasDebit = false;
|
|
@@ -68414,7 +68689,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
68414
68689
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
68415
68690
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68416
68691
|
};
|
|
68417
|
-
var _LedgerAtomicInterface_instances, _LedgerAtomicInterface_network, _LedgerAtomicInterface_subnet, _LedgerAtomicInterface_kind, _LedgerAtomicInterface_privateKey, _LedgerAtomicInterface_computeFeeFromBlocks, _LedgerAtomicInterface_storage, _LedgerAtomicInterface_ledger, _LedgerAtomicInterface_cache, _LedgerAtomicInterface_operations, _LedgerAtomicInterface_transaction, _LedgerAtomicInterface_assertTransaction, _LedgerAtomicInterface_validateVotingWeight, _LedgerAtomicInterface_listAccountInfo, _LedgerAtomicInterface_checkSingleAccountPermissions, _LedgerAtomicInterface_checkPermissionRequirements, _LedgerAtomicInterface_validateBlockOperations, _LedgerAtomicInterface_validateLedgerOutcome, _LedgerAtomicInterface_validateBlocksForVote, _LedgerAtomicInterface_voteOrQuoteWithFees, _Ledger_storage, _Ledger_config;
|
|
68692
|
+
var _LedgerAtomicInterface_instances, _LedgerAtomicInterface_network, _LedgerAtomicInterface_subnet, _LedgerAtomicInterface_kind, _LedgerAtomicInterface_privateKey, _LedgerAtomicInterface_computeFeeFromBlocks, _LedgerAtomicInterface_storage, _LedgerAtomicInterface_ledger, _LedgerAtomicInterface_cache, _LedgerAtomicInterface_operations, _LedgerAtomicInterface_transaction, _LedgerAtomicInterface_assertTransaction, _LedgerAtomicInterface_validateVotingWeight, _LedgerAtomicInterface_listAccountInfo, _LedgerAtomicInterface_fetchSatisfiedCertificateACLs, _LedgerAtomicInterface_checkSingleAccountPermissions, _LedgerAtomicInterface_checkPermissionRequirements, _LedgerAtomicInterface_validateBlockOperations, _LedgerAtomicInterface_validateLedgerOutcome, _LedgerAtomicInterface_validateBlocksForVote, _LedgerAtomicInterface_voteOrQuoteWithFees, _Ledger_storage, _Ledger_config;
|
|
68418
68693
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
68419
68694
|
exports.Ledger = exports.LedgerStorageTransactionBase = exports.IdempotentKey = exports.LedgerKind = void 0;
|
|
68420
68695
|
const vote_1 = __webpack_require__(1130);
|
|
@@ -68430,6 +68705,7 @@ const types_1 = __webpack_require__(5773);
|
|
|
68430
68705
|
const conversion_1 = __webpack_require__(2360);
|
|
68431
68706
|
const cache_1 = __importDefault(__webpack_require__(5834));
|
|
68432
68707
|
const timing_1 = __webpack_require__(2895);
|
|
68708
|
+
const certificate_1 = __webpack_require__(5661);
|
|
68433
68709
|
const operations_1 = __webpack_require__(2778);
|
|
68434
68710
|
const stats_1 = __webpack_require__(2127);
|
|
68435
68711
|
const buffer_1 = __webpack_require__(3310);
|
|
@@ -68974,9 +69250,9 @@ class LedgerAtomicInterface {
|
|
|
68974
69250
|
const permissions = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").listACLsByPrincipal(transaction, principal, entityList);
|
|
68975
69251
|
return (permissions);
|
|
68976
69252
|
}
|
|
68977
|
-
async listACLsByEntity(entity) {
|
|
69253
|
+
async listACLsByEntity(entity, options) {
|
|
68978
69254
|
const transaction = __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
68979
|
-
const permissions = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").listACLsByEntity(transaction, entity);
|
|
69255
|
+
const permissions = await __classPrivateFieldGet(this, _LedgerAtomicInterface_storage, "f").listACLsByEntity(transaction, entity, options);
|
|
68980
69256
|
return (permissions);
|
|
68981
69257
|
}
|
|
68982
69258
|
async votingPower(rep) {
|
|
@@ -69289,6 +69565,63 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
|
|
|
69289
69565
|
});
|
|
69290
69566
|
await Promise.all(permissionPromises);
|
|
69291
69567
|
return (accountInfo);
|
|
69568
|
+
}, _LedgerAtomicInterface_fetchSatisfiedCertificateACLs = async function _LedgerAtomicInterface_fetchSatisfiedCertificateACLs(account, requirement) {
|
|
69569
|
+
const entityCertificateACLs = await this.listACLsByEntity(requirement.entity, { principalType: 'CERTIFICATE' });
|
|
69570
|
+
if (entityCertificateACLs.length === 0) {
|
|
69571
|
+
return (null);
|
|
69572
|
+
}
|
|
69573
|
+
const entityACLsWithValuesResponse = await Promise.all(entityCertificateACLs.map(async (acl) => {
|
|
69574
|
+
if (acl.principalType !== 'CERTIFICATE') {
|
|
69575
|
+
throw (new Error('Expected certificate ACL row'));
|
|
69576
|
+
}
|
|
69577
|
+
const certificate = await this.getAccountCertificateByHash(acl.principal.certificateAccount, acl.principal.certificate);
|
|
69578
|
+
if (certificate === null) {
|
|
69579
|
+
return (null);
|
|
69580
|
+
}
|
|
69581
|
+
return ({ acl, certificate });
|
|
69582
|
+
}));
|
|
69583
|
+
// XXX:TODO does this need to be paginated
|
|
69584
|
+
const userCertificates = await this.getAccountCertificates(account);
|
|
69585
|
+
const matchedCertificateACLs = [];
|
|
69586
|
+
for (const aclWithCertificate of entityACLsWithValuesResponse) {
|
|
69587
|
+
if (!aclWithCertificate) {
|
|
69588
|
+
continue;
|
|
69589
|
+
}
|
|
69590
|
+
const { certificate: aclCertificate, acl } = aclWithCertificate;
|
|
69591
|
+
const issuerCertificate = new certificate_1.Certificate(aclCertificate.certificate, {
|
|
69592
|
+
isTrustedRoot: true
|
|
69593
|
+
});
|
|
69594
|
+
if (!issuerCertificate.checkValid()) {
|
|
69595
|
+
continue;
|
|
69596
|
+
}
|
|
69597
|
+
for (const userCertificate of userCertificates) {
|
|
69598
|
+
if (!userCertificate.certificate.checkValid()) {
|
|
69599
|
+
continue;
|
|
69600
|
+
}
|
|
69601
|
+
const foundChain = userCertificate.certificate.verifyChain({
|
|
69602
|
+
root: new Set([issuerCertificate]),
|
|
69603
|
+
intermediate: new Set([
|
|
69604
|
+
...aclCertificate.intermediates?.getCertificates() ?? [],
|
|
69605
|
+
...userCertificate.intermediates?.getCertificates() ?? []
|
|
69606
|
+
])
|
|
69607
|
+
});
|
|
69608
|
+
if (foundChain === null) {
|
|
69609
|
+
continue;
|
|
69610
|
+
}
|
|
69611
|
+
let foundRootInChain = false;
|
|
69612
|
+
for (const certInChain of foundChain) {
|
|
69613
|
+
if (certInChain.hash().compareHexString(issuerCertificate.hash())) {
|
|
69614
|
+
foundRootInChain = true;
|
|
69615
|
+
break;
|
|
69616
|
+
}
|
|
69617
|
+
}
|
|
69618
|
+
if (!foundRootInChain) {
|
|
69619
|
+
throw (new Error('Internal error: issuer certificate not found in verified chain'));
|
|
69620
|
+
}
|
|
69621
|
+
matchedCertificateACLs.push(acl);
|
|
69622
|
+
}
|
|
69623
|
+
}
|
|
69624
|
+
return (matchedCertificateACLs);
|
|
69292
69625
|
}, _LedgerAtomicInterface_checkSingleAccountPermissions = async function _LedgerAtomicInterface_checkSingleAccountPermissions(account, requirements, accountInfos) {
|
|
69293
69626
|
__classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_assertTransaction).call(this);
|
|
69294
69627
|
// Remove duplicates in entity
|
|
@@ -69296,6 +69629,9 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
|
|
|
69296
69629
|
const entityAccounts = new account_1.default.Set(unfilteredEntity).toArray();
|
|
69297
69630
|
const gotPermissions = await this.listACLsByPrincipal(account, entityAccounts);
|
|
69298
69631
|
for (const requirement of requirements) {
|
|
69632
|
+
if (!requirement.permissions) {
|
|
69633
|
+
throw (new Error('Unexpected null permissions in requirement'));
|
|
69634
|
+
}
|
|
69299
69635
|
const reqEntityKey = requirement.entity.publicKeyString.get();
|
|
69300
69636
|
const foundACLRow = (0, common_1.findPermissionMatch)(requirement, gotPermissions);
|
|
69301
69637
|
const foundAccountInfo = accountInfos[reqEntityKey];
|
|
@@ -69309,10 +69645,19 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
|
|
|
69309
69645
|
else {
|
|
69310
69646
|
foundPermission = new permissions_1.Permissions();
|
|
69311
69647
|
}
|
|
69312
|
-
|
|
69313
|
-
|
|
69648
|
+
let hasPermissions = foundPermission.has(requirement.permissions);
|
|
69649
|
+
if (!hasPermissions && account.isAccount()) {
|
|
69650
|
+
const found = await __classPrivateFieldGet(this, _LedgerAtomicInterface_instances, "m", _LedgerAtomicInterface_fetchSatisfiedCertificateACLs).call(this, account, requirement);
|
|
69651
|
+
if (found) {
|
|
69652
|
+
for (const row of found) {
|
|
69653
|
+
const certificateRowHasPermissions = row.permissions.has(requirement.permissions);
|
|
69654
|
+
if (certificateRowHasPermissions) {
|
|
69655
|
+
hasPermissions = true;
|
|
69656
|
+
break;
|
|
69657
|
+
}
|
|
69658
|
+
}
|
|
69659
|
+
}
|
|
69314
69660
|
}
|
|
69315
|
-
const hasPermissions = foundPermission.has(requirement.permissions);
|
|
69316
69661
|
if (!hasPermissions) {
|
|
69317
69662
|
const accountPubKey = account.publicKeyString.get();
|
|
69318
69663
|
const baseFlagsStr = requirement.permissions.base.flags.join(', ');
|
|
@@ -69328,15 +69673,19 @@ _LedgerAtomicInterface_network = new WeakMap(), _LedgerAtomicInterface_subnet =
|
|
|
69328
69673
|
const needToGetAccountInfoFor = new account_1.default.Set();
|
|
69329
69674
|
const allAccountsChanges = Object.values(effects);
|
|
69330
69675
|
const foundMultisigSignerLengths = [];
|
|
69331
|
-
for (const
|
|
69332
|
-
|
|
69676
|
+
for (const accountChanges of allAccountsChanges) {
|
|
69677
|
+
const { fields } = accountChanges;
|
|
69678
|
+
if (accountChanges.type === 'ACCOUNT' && accountChanges.account.isMultisig()) {
|
|
69333
69679
|
if (fields.minSignerSetLength !== undefined) {
|
|
69334
|
-
needToGetAccountInfoFor.add(account);
|
|
69335
|
-
foundMultisigSignerLengths.push([account, fields.minSignerSetLength]);
|
|
69680
|
+
needToGetAccountInfoFor.add(accountChanges.account);
|
|
69681
|
+
foundMultisigSignerLengths.push([accountChanges.account, fields.minSignerSetLength]);
|
|
69336
69682
|
}
|
|
69337
69683
|
}
|
|
69338
69684
|
for (const singleRequirement of fields.permissionRequirements ?? []) {
|
|
69339
69685
|
const principal = singleRequirement.principal;
|
|
69686
|
+
if (!account_1.default.isInstance(principal)) {
|
|
69687
|
+
throw (new Error('Principal in permission requirement is not an account'));
|
|
69688
|
+
}
|
|
69340
69689
|
const principalPubKey = principal.publicKeyString.get();
|
|
69341
69690
|
if (!requirementsByPrincipal[principalPubKey]) {
|
|
69342
69691
|
requirementsByPrincipal[principalPubKey] = [];
|
|
@@ -69462,6 +69811,9 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
|
|
|
69462
69811
|
}
|
|
69463
69812
|
}
|
|
69464
69813
|
for (const accountChanges of allAccountsChanges) {
|
|
69814
|
+
if (accountChanges.type === 'CERTIFICATE') {
|
|
69815
|
+
continue;
|
|
69816
|
+
}
|
|
69465
69817
|
const { account, fields = {} } = accountChanges;
|
|
69466
69818
|
/**
|
|
69467
69819
|
* Newly created identifiers automatically grant the creator ownership.
|
|
@@ -69475,6 +69827,10 @@ async function _LedgerAtomicInterface_validateLedgerOutcome(blocks) {
|
|
|
69475
69827
|
*/
|
|
69476
69828
|
const addedPermissions = fields.permissions ?? [];
|
|
69477
69829
|
for (const newPerm of addedPermissions) {
|
|
69830
|
+
// We only care about permissions that include ownership, and non-accounts (ex: certificate principals) cannot be owners
|
|
69831
|
+
if (newPerm.principalType === 'CERTIFICATE') {
|
|
69832
|
+
continue;
|
|
69833
|
+
}
|
|
69478
69834
|
let method = 'ADD';
|
|
69479
69835
|
if (newPerm.permissions === null || !newPerm.permissions.has(['OWNER'])) {
|
|
69480
69836
|
method = 'REMOVE';
|
|
@@ -69993,7 +70349,7 @@ exports["default"] = Ledger;
|
|
|
69993
70349
|
/***/ }),
|
|
69994
70350
|
|
|
69995
70351
|
/***/ 5773:
|
|
69996
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
70352
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
69997
70353
|
|
|
69998
70354
|
"use strict";
|
|
69999
70355
|
|
|
@@ -70001,6 +70357,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
70001
70357
|
exports.isIdentifierAccountInfo = isIdentifierAccountInfo;
|
|
70002
70358
|
exports.isKeyPairAccountInfo = isKeyPairAccountInfo;
|
|
70003
70359
|
exports.isAccountInfoOfType = isAccountInfoOfType;
|
|
70360
|
+
exports.isACLPrincipalType = isACLPrincipalType;
|
|
70361
|
+
exports.assertACLPrincipalType = assertACLPrincipalType;
|
|
70362
|
+
exports.asACLPrincipalType = asACLPrincipalType;
|
|
70363
|
+
const ledger_1 = __webpack_require__(452);
|
|
70004
70364
|
function isIdentifierAccountInfo(info) {
|
|
70005
70365
|
return (info.account.isIdentifier());
|
|
70006
70366
|
}
|
|
@@ -70010,6 +70370,20 @@ function isKeyPairAccountInfo(info) {
|
|
|
70010
70370
|
function isAccountInfoOfType(info, type) {
|
|
70011
70371
|
return (info.account.isKeyType(type));
|
|
70012
70372
|
}
|
|
70373
|
+
const aclPrincipalType = ['ACCOUNT', 'CERTIFICATE'];
|
|
70374
|
+
function isACLPrincipalType(type) {
|
|
70375
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
70376
|
+
return (aclPrincipalType.includes(type));
|
|
70377
|
+
}
|
|
70378
|
+
function assertACLPrincipalType(type) {
|
|
70379
|
+
if (!isACLPrincipalType(type)) {
|
|
70380
|
+
throw (new ledger_1.KeetaNetLedgerError('LEDGER_INVALID_ACL_ROW_TYPE', `Invalid ACL Row Type: ${type}`));
|
|
70381
|
+
}
|
|
70382
|
+
}
|
|
70383
|
+
function asACLPrincipalType(type) {
|
|
70384
|
+
assertACLPrincipalType(type);
|
|
70385
|
+
return (type);
|
|
70386
|
+
}
|
|
70013
70387
|
|
|
70014
70388
|
|
|
70015
70389
|
/***/ }),
|
|
@@ -80856,7 +81230,7 @@ exports.Testing = { findRDN, blockHashesFromVote, feeFromVote, hashDataSchema, f
|
|
|
80856
81230
|
|
|
80857
81231
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
80858
81232
|
exports.version = void 0;
|
|
80859
|
-
exports.version = '0.
|
|
81233
|
+
exports.version = '0.18.0+g5417d9af948be899fcebb75694edb492ff971891';
|
|
80860
81234
|
exports["default"] = exports.version;
|
|
80861
81235
|
|
|
80862
81236
|
|