@0xpolygonid/js-sdk 1.23.0 → 1.24.1
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/dist/browser/esm/index.js +3103 -358
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +3106 -356
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/credentials/credential-wallet.js +11 -78
- package/dist/node/cjs/credentials/index.js +1 -0
- package/dist/node/cjs/credentials/status/did-resolver-revocation.js +21 -0
- package/dist/node/cjs/iden3comm/handlers/fetch.js +32 -0
- package/dist/node/cjs/iden3comm/handlers/payment.js +38 -13
- package/dist/node/cjs/storage/blockchain/abi/ERC20.json +1 -0
- package/dist/node/cjs/storage/blockchain/did-resolver-readonly-storage.js +72 -0
- package/dist/node/cjs/storage/blockchain/{erc20-permit-sig.js → erc20-helper.js} +14 -1
- package/dist/node/cjs/storage/blockchain/index.js +3 -1
- package/dist/node/cjs/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +245 -0
- package/dist/node/cjs/storage/blockchain/onchain-issuer.js +82 -0
- package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +38 -34
- package/dist/node/cjs/storage/interfaces/index.js +1 -0
- package/dist/node/cjs/storage/interfaces/onchain-issuer.js +2 -0
- package/dist/node/cjs/utils/did-helper.js +3 -3
- package/dist/node/cjs/verifiable/constants.js +1 -0
- package/dist/node/cjs/verifiable/credential.js +86 -0
- package/dist/node/esm/credentials/credential-wallet.js +12 -79
- package/dist/node/esm/credentials/index.js +1 -0
- package/dist/node/esm/credentials/status/did-resolver-revocation.js +17 -0
- package/dist/node/esm/iden3comm/handlers/fetch.js +32 -0
- package/dist/node/esm/iden3comm/handlers/payment.js +38 -14
- package/dist/node/esm/storage/blockchain/abi/ERC20.json +1 -0
- package/dist/node/esm/storage/blockchain/did-resolver-readonly-storage.js +68 -0
- package/dist/node/esm/storage/blockchain/{erc20-permit-sig.js → erc20-helper.js} +14 -2
- package/dist/node/esm/storage/blockchain/index.js +3 -1
- package/dist/node/esm/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +241 -0
- package/dist/node/esm/storage/blockchain/onchain-issuer.js +78 -0
- package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +38 -34
- package/dist/node/esm/storage/interfaces/index.js +1 -0
- package/dist/node/esm/storage/interfaces/onchain-issuer.js +1 -0
- package/dist/node/esm/utils/did-helper.js +3 -3
- package/dist/node/esm/verifiable/constants.js +1 -0
- package/dist/node/esm/verifiable/credential.js +88 -2
- package/dist/types/credentials/credential-wallet.d.ts +0 -6
- package/dist/types/credentials/index.d.ts +1 -0
- package/dist/types/credentials/models.d.ts +8 -0
- package/dist/types/credentials/status/did-resolver-revocation.d.ts +7 -0
- package/dist/types/iden3comm/handlers/fetch.d.ts +8 -0
- package/dist/types/iden3comm/handlers/payment.d.ts +3 -2
- package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts +16 -0
- package/dist/types/storage/blockchain/{erc20-permit-sig.d.ts → erc20-helper.d.ts} +8 -1
- package/dist/types/storage/blockchain/index.d.ts +3 -1
- package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts +66 -0
- package/dist/types/storage/blockchain/onchain-issuer.d.ts +40 -0
- package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +11 -12
- package/dist/types/storage/entities/state.d.ts +2 -0
- package/dist/types/storage/interfaces/index.d.ts +1 -0
- package/dist/types/storage/interfaces/onchain-issuer.d.ts +12 -0
- package/dist/types/verifiable/constants.d.ts +1 -0
- package/dist/types/verifiable/credential.d.ts +15 -2
- package/package.json +3 -2
|
@@ -1396,7 +1396,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
1396
1396
|
}
|
|
1397
1397
|
};
|
|
1398
1398
|
const resolveDIDDocumentAuth = async (did, resolveURL, state) => {
|
|
1399
|
-
let url = `${resolveURL}/${did.string()
|
|
1399
|
+
let url = `${resolveURL}/${encodeURIComponent(did.string())}`;
|
|
1400
1400
|
if (state) {
|
|
1401
1401
|
url += `?state=${state.hex()}`;
|
|
1402
1402
|
}
|
|
@@ -1412,11 +1412,11 @@ var PolygonIdSdk = (function (exports) {
|
|
|
1412
1412
|
return emptyDID;
|
|
1413
1413
|
}
|
|
1414
1414
|
const resolveDidDocument = async (did, resolverUrl, opts) => {
|
|
1415
|
-
let didString = did.string()
|
|
1415
|
+
let didString = encodeURIComponent(did.string());
|
|
1416
1416
|
// for gist resolve we have to `hide` user did (look into resolver implementation)
|
|
1417
1417
|
const isGistRequest = opts?.gist && !opts.state;
|
|
1418
1418
|
if (isGistRequest) {
|
|
1419
|
-
didString = emptyStateDID(did).string();
|
|
1419
|
+
didString = encodeURIComponent(emptyStateDID(did).string());
|
|
1420
1420
|
}
|
|
1421
1421
|
let url = `${resolverUrl}/1.0/identifiers/${didString}`;
|
|
1422
1422
|
if (opts?.signature) {
|
|
@@ -5451,7 +5451,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
5451
5451
|
throw new Error('Unknown type, must be binary type');
|
|
5452
5452
|
};
|
|
5453
5453
|
const fromString$2 = str => new TextEncoder().encode(str);
|
|
5454
|
-
const toString$
|
|
5454
|
+
const toString$8 = b => new TextDecoder().decode(b);
|
|
5455
5455
|
|
|
5456
5456
|
class Encoder {
|
|
5457
5457
|
constructor(name, prefix, baseEncode) {
|
|
@@ -5608,7 +5608,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
5608
5608
|
const identity$1 = from({
|
|
5609
5609
|
prefix: '\0',
|
|
5610
5610
|
name: 'identity',
|
|
5611
|
-
encode: buf => toString$
|
|
5611
|
+
encode: buf => toString$8(buf),
|
|
5612
5612
|
decode: str => fromString$2(str)
|
|
5613
5613
|
});
|
|
5614
5614
|
|
|
@@ -5972,7 +5972,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
5972
5972
|
return base.decoder.decode(`${ base.prefix }${ string }`);
|
|
5973
5973
|
}
|
|
5974
5974
|
|
|
5975
|
-
function toString$
|
|
5975
|
+
function toString$7(array, encoding = 'utf8') {
|
|
5976
5976
|
const base = BASES[encoding];
|
|
5977
5977
|
if (!base) {
|
|
5978
5978
|
throw new Error(`Unsupported encoding "${ encoding }"`);
|
|
@@ -6366,19 +6366,19 @@ var PolygonIdSdk = (function (exports) {
|
|
|
6366
6366
|
];
|
|
6367
6367
|
|
|
6368
6368
|
/** @type {Record<BaseName,Base>} */
|
|
6369
|
-
const names$
|
|
6369
|
+
const names$2 = constants$2.reduce((prev, tupple) => {
|
|
6370
6370
|
prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]);
|
|
6371
6371
|
return prev
|
|
6372
6372
|
}, /** @type {Record<BaseName,Base>} */({}));
|
|
6373
6373
|
|
|
6374
6374
|
/** @type {Record<BaseCode,Base>} */
|
|
6375
6375
|
const codes$1 = constants$2.reduce((prev, tupple) => {
|
|
6376
|
-
prev[tupple[1]] = names$
|
|
6376
|
+
prev[tupple[1]] = names$2[tupple[0]];
|
|
6377
6377
|
return prev
|
|
6378
6378
|
}, /** @type {Record<BaseCode,Base>} */({}));
|
|
6379
6379
|
|
|
6380
6380
|
var constants_1 = {
|
|
6381
|
-
names: names$
|
|
6381
|
+
names: names$2,
|
|
6382
6382
|
codes: codes$1
|
|
6383
6383
|
};
|
|
6384
6384
|
|
|
@@ -7150,7 +7150,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
7150
7150
|
const bech32 = /* @__PURE__ */ genBech32('bech32');
|
|
7151
7151
|
|
|
7152
7152
|
const u8a$2 = {
|
|
7153
|
-
toString: toString$
|
|
7153
|
+
toString: toString$7,
|
|
7154
7154
|
fromString: fromString$1,
|
|
7155
7155
|
concat: concat$2
|
|
7156
7156
|
};
|
|
@@ -7348,7 +7348,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
7348
7348
|
const keccak = keccak_256$1;
|
|
7349
7349
|
function toEthereumAddress(hexPublicKey) {
|
|
7350
7350
|
const hashInput = fromString$1(hexPublicKey.slice(2), 'base16');
|
|
7351
|
-
return `0x${toString$
|
|
7351
|
+
return `0x${toString$7(keccak(hashInput).slice(-20), 'base16')}`;
|
|
7352
7352
|
}
|
|
7353
7353
|
|
|
7354
7354
|
/**
|
|
@@ -7880,6 +7880,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
7880
7880
|
SupportedCurrencies["ETH_WEI"] = "ETHWEI";
|
|
7881
7881
|
SupportedCurrencies["ETH_GWEI"] = "ETHGWEI";
|
|
7882
7882
|
SupportedCurrencies["MATIC"] = "MATIC";
|
|
7883
|
+
SupportedCurrencies["POL"] = "POL";
|
|
7883
7884
|
SupportedCurrencies["USDT"] = "USDT";
|
|
7884
7885
|
SupportedCurrencies["USDC"] = "USDC";
|
|
7885
7886
|
})(exports.SupportedCurrencies || (exports.SupportedCurrencies = {}));
|
|
@@ -20038,6 +20039,92 @@ var PolygonIdSdk = (function (exports) {
|
|
|
20038
20039
|
this.credentialSubject = {};
|
|
20039
20040
|
this.issuer = '';
|
|
20040
20041
|
}
|
|
20042
|
+
/**
|
|
20043
|
+
*
|
|
20044
|
+
* @param issuer - DID of the issuer
|
|
20045
|
+
* @param request - Credential request
|
|
20046
|
+
* @returns - W3C Credential
|
|
20047
|
+
*/
|
|
20048
|
+
static fromCredentialRequest(issuer, request) {
|
|
20049
|
+
if (!request.id) {
|
|
20050
|
+
throw new Error('Credential id is required');
|
|
20051
|
+
}
|
|
20052
|
+
if (!request.context) {
|
|
20053
|
+
throw new Error('Credential context is required');
|
|
20054
|
+
}
|
|
20055
|
+
const context = [
|
|
20056
|
+
VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,
|
|
20057
|
+
VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL,
|
|
20058
|
+
...request.context
|
|
20059
|
+
];
|
|
20060
|
+
const credentialType = [
|
|
20061
|
+
VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,
|
|
20062
|
+
request.type
|
|
20063
|
+
];
|
|
20064
|
+
const credentialSubject = request.credentialSubject;
|
|
20065
|
+
credentialSubject['type'] = request.type;
|
|
20066
|
+
const cr = new W3CCredential();
|
|
20067
|
+
cr.id = request.id;
|
|
20068
|
+
cr['@context'] = context;
|
|
20069
|
+
cr.type = credentialType;
|
|
20070
|
+
cr.credentialSubject = credentialSubject;
|
|
20071
|
+
cr.issuer = issuer.string();
|
|
20072
|
+
cr.credentialSchema = {
|
|
20073
|
+
id: request.credentialSchema,
|
|
20074
|
+
type: VerifiableConstants.JSON_SCHEMA_VALIDATOR
|
|
20075
|
+
};
|
|
20076
|
+
cr.credentialStatus = W3CCredential.buildCredentialStatus(request, issuer);
|
|
20077
|
+
request.expiration && (cr.expirationDate = new Date(request.expiration).toISOString());
|
|
20078
|
+
request.refreshService && (cr.refreshService = request.refreshService);
|
|
20079
|
+
request.displayMethod && (cr.displayMethod = request.displayMethod);
|
|
20080
|
+
request.issuanceDate && (cr.issuanceDate = new Date(request.issuanceDate).toISOString());
|
|
20081
|
+
return cr;
|
|
20082
|
+
}
|
|
20083
|
+
/**
|
|
20084
|
+
* Builds credential status
|
|
20085
|
+
* @param {CredentialRequest} request
|
|
20086
|
+
* @returns `CredentialStatus`
|
|
20087
|
+
*/
|
|
20088
|
+
static buildCredentialStatus(request, issuer) {
|
|
20089
|
+
const credentialStatus = {
|
|
20090
|
+
id: request.revocationOpts.id,
|
|
20091
|
+
type: request.revocationOpts.type,
|
|
20092
|
+
revocationNonce: request.revocationOpts.nonce
|
|
20093
|
+
};
|
|
20094
|
+
switch (request.revocationOpts.type) {
|
|
20095
|
+
case exports.CredentialStatusType.SparseMerkleTreeProof:
|
|
20096
|
+
return {
|
|
20097
|
+
...credentialStatus,
|
|
20098
|
+
id: `${credentialStatus.id.replace(/\/$/, '')}/${credentialStatus.revocationNonce}`
|
|
20099
|
+
};
|
|
20100
|
+
case exports.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
|
|
20101
|
+
return {
|
|
20102
|
+
...credentialStatus,
|
|
20103
|
+
id: request.revocationOpts.issuerState
|
|
20104
|
+
? `${credentialStatus.id.replace(/\/$/, '')}/node?state=${request.revocationOpts.issuerState}`
|
|
20105
|
+
: `${credentialStatus.id.replace(/\/$/, '')}`
|
|
20106
|
+
};
|
|
20107
|
+
case exports.CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023: {
|
|
20108
|
+
const issuerId = Q$2.idFromDID(issuer);
|
|
20109
|
+
const chainId = et$2(Q$2.blockchainFromId(issuerId), Q$2.networkIdFromId(issuerId));
|
|
20110
|
+
const searchParams = [
|
|
20111
|
+
['revocationNonce', request.revocationOpts.nonce?.toString() || ''],
|
|
20112
|
+
['contractAddress', `${chainId}:${request.revocationOpts.id}`],
|
|
20113
|
+
['state', request.revocationOpts.issuerState || '']
|
|
20114
|
+
]
|
|
20115
|
+
.filter(([, value]) => Boolean(value))
|
|
20116
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
20117
|
+
.join('&');
|
|
20118
|
+
return {
|
|
20119
|
+
...credentialStatus,
|
|
20120
|
+
// `[did]:[methodid]:[chain]:[network]:[id]/credentialStatus?(revocationNonce=value)&[contractAddress=[chainID]:[contractAddress]]&(state=issuerState)`
|
|
20121
|
+
id: `${issuer.string()}/credentialStatus?${searchParams}`
|
|
20122
|
+
};
|
|
20123
|
+
}
|
|
20124
|
+
default:
|
|
20125
|
+
return credentialStatus;
|
|
20126
|
+
}
|
|
20127
|
+
}
|
|
20041
20128
|
toJSON() {
|
|
20042
20129
|
return {
|
|
20043
20130
|
...this,
|
|
@@ -22414,16 +22501,16 @@ var PolygonIdSdk = (function (exports) {
|
|
|
22414
22501
|
|
|
22415
22502
|
} (util));
|
|
22416
22503
|
|
|
22417
|
-
var names = {};
|
|
22504
|
+
var names$1 = {};
|
|
22418
22505
|
|
|
22419
22506
|
var hasRequiredNames;
|
|
22420
22507
|
|
|
22421
22508
|
function requireNames () {
|
|
22422
|
-
if (hasRequiredNames) return names;
|
|
22509
|
+
if (hasRequiredNames) return names$1;
|
|
22423
22510
|
hasRequiredNames = 1;
|
|
22424
|
-
Object.defineProperty(names, "__esModule", { value: true });
|
|
22511
|
+
Object.defineProperty(names$1, "__esModule", { value: true });
|
|
22425
22512
|
const codegen_1 = requireCodegen();
|
|
22426
|
-
const names
|
|
22513
|
+
const names = {
|
|
22427
22514
|
// validation function arguments
|
|
22428
22515
|
data: new codegen_1.Name("data"),
|
|
22429
22516
|
// args passed from referencing schema
|
|
@@ -22446,9 +22533,9 @@ var PolygonIdSdk = (function (exports) {
|
|
|
22446
22533
|
jsonLen: new codegen_1.Name("jsonLen"),
|
|
22447
22534
|
jsonPart: new codegen_1.Name("jsonPart"),
|
|
22448
22535
|
};
|
|
22449
|
-
names.default = names
|
|
22536
|
+
names$1.default = names;
|
|
22450
22537
|
|
|
22451
|
-
return names;
|
|
22538
|
+
return names$1;
|
|
22452
22539
|
}
|
|
22453
22540
|
|
|
22454
22541
|
var hasRequiredErrors;
|
|
@@ -30882,8 +30969,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
30882
30969
|
*
|
|
30883
30970
|
* @_subsection: api/utils:Math Helpers [about-maths]
|
|
30884
30971
|
*/
|
|
30885
|
-
const BN_0$
|
|
30886
|
-
const BN_1$
|
|
30972
|
+
const BN_0$9 = BigInt(0);
|
|
30973
|
+
const BN_1$4 = BigInt(1);
|
|
30887
30974
|
//const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;
|
|
30888
30975
|
// IEEE 754 support 53-bits of mantissa
|
|
30889
30976
|
const maxValue = 0x1fffffffffffff;
|
|
@@ -30896,13 +30983,13 @@ var PolygonIdSdk = (function (exports) {
|
|
|
30896
30983
|
function fromTwos(_value, _width) {
|
|
30897
30984
|
const value = getUint(_value, "value");
|
|
30898
30985
|
const width = BigInt(getNumber(_width, "width"));
|
|
30899
|
-
assert$2((value >> width) === BN_0$
|
|
30986
|
+
assert$2((value >> width) === BN_0$9, "overflow", "NUMERIC_FAULT", {
|
|
30900
30987
|
operation: "fromTwos", fault: "overflow", value: _value
|
|
30901
30988
|
});
|
|
30902
30989
|
// Top bit set; treat as a negative value
|
|
30903
|
-
if (value >> (width - BN_1$
|
|
30904
|
-
const mask = (BN_1$
|
|
30905
|
-
return -(((~value) & mask) + BN_1$
|
|
30990
|
+
if (value >> (width - BN_1$4)) {
|
|
30991
|
+
const mask = (BN_1$4 << width) - BN_1$4;
|
|
30992
|
+
return -(((~value) & mask) + BN_1$4);
|
|
30906
30993
|
}
|
|
30907
30994
|
return value;
|
|
30908
30995
|
}
|
|
@@ -30915,14 +31002,14 @@ var PolygonIdSdk = (function (exports) {
|
|
|
30915
31002
|
function toTwos(_value, _width) {
|
|
30916
31003
|
let value = getBigInt(_value, "value");
|
|
30917
31004
|
const width = BigInt(getNumber(_width, "width"));
|
|
30918
|
-
const limit = (BN_1$
|
|
30919
|
-
if (value < BN_0$
|
|
31005
|
+
const limit = (BN_1$4 << (width - BN_1$4));
|
|
31006
|
+
if (value < BN_0$9) {
|
|
30920
31007
|
value = -value;
|
|
30921
31008
|
assert$2(value <= limit, "too low", "NUMERIC_FAULT", {
|
|
30922
31009
|
operation: "toTwos", fault: "overflow", value: _value
|
|
30923
31010
|
});
|
|
30924
|
-
const mask = (BN_1$
|
|
30925
|
-
return ((~value) & mask) + BN_1$
|
|
31011
|
+
const mask = (BN_1$4 << width) - BN_1$4;
|
|
31012
|
+
return ((~value) & mask) + BN_1$4;
|
|
30926
31013
|
}
|
|
30927
31014
|
else {
|
|
30928
31015
|
assert$2(value < limit, "too high", "NUMERIC_FAULT", {
|
|
@@ -30937,7 +31024,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
30937
31024
|
function mask(_value, _bits) {
|
|
30938
31025
|
const value = getUint(_value, "value");
|
|
30939
31026
|
const bits = BigInt(getNumber(_bits, "bits"));
|
|
30940
|
-
return value & ((BN_1$
|
|
31027
|
+
return value & ((BN_1$4 << bits) - BN_1$4);
|
|
30941
31028
|
}
|
|
30942
31029
|
/**
|
|
30943
31030
|
* Gets a BigInt from %%value%%. If it is an invalid value for
|
|
@@ -30972,7 +31059,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
30972
31059
|
*/
|
|
30973
31060
|
function getUint(value, name) {
|
|
30974
31061
|
const result = getBigInt(value, name);
|
|
30975
|
-
assert$2(result >= BN_0$
|
|
31062
|
+
assert$2(result >= BN_0$9, "unsigned value cannot be negative", "NUMERIC_FAULT", {
|
|
30976
31063
|
fault: "overflow", operation: "getUint", value
|
|
30977
31064
|
});
|
|
30978
31065
|
return result;
|
|
@@ -31058,7 +31145,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
31058
31145
|
*/
|
|
31059
31146
|
function toBeArray(_value) {
|
|
31060
31147
|
const value = getUint(_value, "value");
|
|
31061
|
-
if (value === BN_0$
|
|
31148
|
+
if (value === BN_0$9) {
|
|
31062
31149
|
return new Uint8Array([]);
|
|
31063
31150
|
}
|
|
31064
31151
|
let hex = value.toString(16);
|
|
@@ -32290,6 +32377,526 @@ var PolygonIdSdk = (function (exports) {
|
|
|
32290
32377
|
return new Promise((resolve) => setTimeout(resolve, delay));
|
|
32291
32378
|
}
|
|
32292
32379
|
|
|
32380
|
+
/**
|
|
32381
|
+
* The **FixedNumber** class permits using values with decimal places,
|
|
32382
|
+
* using fixed-pont math.
|
|
32383
|
+
*
|
|
32384
|
+
* Fixed-point math is still based on integers under-the-hood, but uses an
|
|
32385
|
+
* internal offset to store fractional components below, and each operation
|
|
32386
|
+
* corrects for this after each operation.
|
|
32387
|
+
*
|
|
32388
|
+
* @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
|
|
32389
|
+
*/
|
|
32390
|
+
const BN_N1 = BigInt(-1);
|
|
32391
|
+
const BN_0$8 = BigInt(0);
|
|
32392
|
+
const BN_1$3 = BigInt(1);
|
|
32393
|
+
const BN_5 = BigInt(5);
|
|
32394
|
+
const _guard$3 = {};
|
|
32395
|
+
// Constant to pull zeros from for multipliers
|
|
32396
|
+
let Zeros$1 = "0000";
|
|
32397
|
+
while (Zeros$1.length < 80) {
|
|
32398
|
+
Zeros$1 += Zeros$1;
|
|
32399
|
+
}
|
|
32400
|
+
// Returns a string "1" followed by decimal "0"s
|
|
32401
|
+
function getTens(decimals) {
|
|
32402
|
+
let result = Zeros$1;
|
|
32403
|
+
while (result.length < decimals) {
|
|
32404
|
+
result += result;
|
|
32405
|
+
}
|
|
32406
|
+
return BigInt("1" + result.substring(0, decimals));
|
|
32407
|
+
}
|
|
32408
|
+
function checkValue(val, format, safeOp) {
|
|
32409
|
+
const width = BigInt(format.width);
|
|
32410
|
+
if (format.signed) {
|
|
32411
|
+
const limit = (BN_1$3 << (width - BN_1$3));
|
|
32412
|
+
assert$2(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
|
|
32413
|
+
operation: safeOp, fault: "overflow", value: val
|
|
32414
|
+
});
|
|
32415
|
+
if (val > BN_0$8) {
|
|
32416
|
+
val = fromTwos(mask(val, width), width);
|
|
32417
|
+
}
|
|
32418
|
+
else {
|
|
32419
|
+
val = -fromTwos(mask(-val, width), width);
|
|
32420
|
+
}
|
|
32421
|
+
}
|
|
32422
|
+
else {
|
|
32423
|
+
const limit = (BN_1$3 << width);
|
|
32424
|
+
assert$2(safeOp == null || (val >= 0 && val < limit), "overflow", "NUMERIC_FAULT", {
|
|
32425
|
+
operation: safeOp, fault: "overflow", value: val
|
|
32426
|
+
});
|
|
32427
|
+
val = (((val % limit) + limit) % limit) & (limit - BN_1$3);
|
|
32428
|
+
}
|
|
32429
|
+
return val;
|
|
32430
|
+
}
|
|
32431
|
+
function getFormat(value) {
|
|
32432
|
+
if (typeof (value) === "number") {
|
|
32433
|
+
value = `fixed128x${value}`;
|
|
32434
|
+
}
|
|
32435
|
+
let signed = true;
|
|
32436
|
+
let width = 128;
|
|
32437
|
+
let decimals = 18;
|
|
32438
|
+
if (typeof (value) === "string") {
|
|
32439
|
+
// Parse the format string
|
|
32440
|
+
if (value === "fixed") ;
|
|
32441
|
+
else if (value === "ufixed") {
|
|
32442
|
+
signed = false;
|
|
32443
|
+
}
|
|
32444
|
+
else {
|
|
32445
|
+
const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
|
|
32446
|
+
assertArgument(match, "invalid fixed format", "format", value);
|
|
32447
|
+
signed = (match[1] !== "u");
|
|
32448
|
+
width = parseInt(match[2]);
|
|
32449
|
+
decimals = parseInt(match[3]);
|
|
32450
|
+
}
|
|
32451
|
+
}
|
|
32452
|
+
else if (value) {
|
|
32453
|
+
// Extract the values from the object
|
|
32454
|
+
const v = value;
|
|
32455
|
+
const check = (key, type, defaultValue) => {
|
|
32456
|
+
if (v[key] == null) {
|
|
32457
|
+
return defaultValue;
|
|
32458
|
+
}
|
|
32459
|
+
assertArgument(typeof (v[key]) === type, "invalid fixed format (" + key + " not " + type + ")", "format." + key, v[key]);
|
|
32460
|
+
return v[key];
|
|
32461
|
+
};
|
|
32462
|
+
signed = check("signed", "boolean", signed);
|
|
32463
|
+
width = check("width", "number", width);
|
|
32464
|
+
decimals = check("decimals", "number", decimals);
|
|
32465
|
+
}
|
|
32466
|
+
assertArgument((width % 8) === 0, "invalid FixedNumber width (not byte aligned)", "format.width", width);
|
|
32467
|
+
assertArgument(decimals <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", decimals);
|
|
32468
|
+
const name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals);
|
|
32469
|
+
return { signed, width, decimals, name };
|
|
32470
|
+
}
|
|
32471
|
+
function toString$6(val, decimals) {
|
|
32472
|
+
let negative = "";
|
|
32473
|
+
if (val < BN_0$8) {
|
|
32474
|
+
negative = "-";
|
|
32475
|
+
val *= BN_N1;
|
|
32476
|
+
}
|
|
32477
|
+
let str = val.toString();
|
|
32478
|
+
// No decimal point for whole values
|
|
32479
|
+
if (decimals === 0) {
|
|
32480
|
+
return (negative + str);
|
|
32481
|
+
}
|
|
32482
|
+
// Pad out to the whole component (including a whole digit)
|
|
32483
|
+
while (str.length <= decimals) {
|
|
32484
|
+
str = Zeros$1 + str;
|
|
32485
|
+
}
|
|
32486
|
+
// Insert the decimal point
|
|
32487
|
+
const index = str.length - decimals;
|
|
32488
|
+
str = str.substring(0, index) + "." + str.substring(index);
|
|
32489
|
+
// Trim the whole component (leaving at least one 0)
|
|
32490
|
+
while (str[0] === "0" && str[1] !== ".") {
|
|
32491
|
+
str = str.substring(1);
|
|
32492
|
+
}
|
|
32493
|
+
// Trim the decimal component (leaving at least one 0)
|
|
32494
|
+
while (str[str.length - 1] === "0" && str[str.length - 2] !== ".") {
|
|
32495
|
+
str = str.substring(0, str.length - 1);
|
|
32496
|
+
}
|
|
32497
|
+
return (negative + str);
|
|
32498
|
+
}
|
|
32499
|
+
/**
|
|
32500
|
+
* A FixedNumber represents a value over its [[FixedFormat]]
|
|
32501
|
+
* arithmetic field.
|
|
32502
|
+
*
|
|
32503
|
+
* A FixedNumber can be used to perform math, losslessly, on
|
|
32504
|
+
* values which have decmial places.
|
|
32505
|
+
*
|
|
32506
|
+
* A FixedNumber has a fixed bit-width to store values in, and stores all
|
|
32507
|
+
* values internally by multiplying the value by 10 raised to the power of
|
|
32508
|
+
* %%decimals%%.
|
|
32509
|
+
*
|
|
32510
|
+
* If operations are performed that cause a value to grow too high (close to
|
|
32511
|
+
* positive infinity) or too low (close to negative infinity), the value
|
|
32512
|
+
* is said to //overflow//.
|
|
32513
|
+
*
|
|
32514
|
+
* For example, an 8-bit signed value, with 0 decimals may only be within
|
|
32515
|
+
* the range ``-128`` to ``127``; so ``-128 - 1`` will overflow and become
|
|
32516
|
+
* ``127``. Likewise, ``127 + 1`` will overflow and become ``-127``.
|
|
32517
|
+
*
|
|
32518
|
+
* Many operation have a normal and //unsafe// variant. The normal variant
|
|
32519
|
+
* will throw a [[NumericFaultError]] on any overflow, while the //unsafe//
|
|
32520
|
+
* variant will silently allow overflow, corrupting its value value.
|
|
32521
|
+
*
|
|
32522
|
+
* If operations are performed that cause a value to become too small
|
|
32523
|
+
* (close to zero), the value loses precison and is said to //underflow//.
|
|
32524
|
+
*
|
|
32525
|
+
* For example, an value with 1 decimal place may store a number as small
|
|
32526
|
+
* as ``0.1``, but the value of ``0.1 / 2`` is ``0.05``, which cannot fit
|
|
32527
|
+
* into 1 decimal place, so underflow occurs which means precision is lost
|
|
32528
|
+
* and the value becomes ``0``.
|
|
32529
|
+
*
|
|
32530
|
+
* Some operations have a normal and //signalling// variant. The normal
|
|
32531
|
+
* variant will silently ignore underflow, while the //signalling// variant
|
|
32532
|
+
* will thow a [[NumericFaultError]] on underflow.
|
|
32533
|
+
*/
|
|
32534
|
+
class FixedNumber {
|
|
32535
|
+
/**
|
|
32536
|
+
* The specific fixed-point arithmetic field for this value.
|
|
32537
|
+
*/
|
|
32538
|
+
format;
|
|
32539
|
+
#format;
|
|
32540
|
+
// The actual value (accounting for decimals)
|
|
32541
|
+
#val;
|
|
32542
|
+
// A base-10 value to multiple values by to maintain the magnitude
|
|
32543
|
+
#tens;
|
|
32544
|
+
/**
|
|
32545
|
+
* This is a property so console.log shows a human-meaningful value.
|
|
32546
|
+
*
|
|
32547
|
+
* @private
|
|
32548
|
+
*/
|
|
32549
|
+
_value;
|
|
32550
|
+
// Use this when changing this file to get some typing info,
|
|
32551
|
+
// but then switch to any to mask the internal type
|
|
32552
|
+
//constructor(guard: any, value: bigint, format: _FixedFormat) {
|
|
32553
|
+
/**
|
|
32554
|
+
* @private
|
|
32555
|
+
*/
|
|
32556
|
+
constructor(guard, value, format) {
|
|
32557
|
+
assertPrivate(guard, _guard$3, "FixedNumber");
|
|
32558
|
+
this.#val = value;
|
|
32559
|
+
this.#format = format;
|
|
32560
|
+
const _value = toString$6(value, format.decimals);
|
|
32561
|
+
defineProperties(this, { format: format.name, _value });
|
|
32562
|
+
this.#tens = getTens(format.decimals);
|
|
32563
|
+
}
|
|
32564
|
+
/**
|
|
32565
|
+
* If true, negative values are permitted, otherwise only
|
|
32566
|
+
* positive values and zero are allowed.
|
|
32567
|
+
*/
|
|
32568
|
+
get signed() { return this.#format.signed; }
|
|
32569
|
+
/**
|
|
32570
|
+
* The number of bits available to store the value.
|
|
32571
|
+
*/
|
|
32572
|
+
get width() { return this.#format.width; }
|
|
32573
|
+
/**
|
|
32574
|
+
* The number of decimal places in the fixed-point arithment field.
|
|
32575
|
+
*/
|
|
32576
|
+
get decimals() { return this.#format.decimals; }
|
|
32577
|
+
/**
|
|
32578
|
+
* The value as an integer, based on the smallest unit the
|
|
32579
|
+
* [[decimals]] allow.
|
|
32580
|
+
*/
|
|
32581
|
+
get value() { return this.#val; }
|
|
32582
|
+
#checkFormat(other) {
|
|
32583
|
+
assertArgument(this.format === other.format, "incompatible format; use fixedNumber.toFormat", "other", other);
|
|
32584
|
+
}
|
|
32585
|
+
#checkValue(val, safeOp) {
|
|
32586
|
+
/*
|
|
32587
|
+
const width = BigInt(this.width);
|
|
32588
|
+
if (this.signed) {
|
|
32589
|
+
const limit = (BN_1 << (width - BN_1));
|
|
32590
|
+
assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
|
|
32591
|
+
operation: <string>safeOp, fault: "overflow", value: val
|
|
32592
|
+
});
|
|
32593
|
+
|
|
32594
|
+
if (val > BN_0) {
|
|
32595
|
+
val = fromTwos(mask(val, width), width);
|
|
32596
|
+
} else {
|
|
32597
|
+
val = -fromTwos(mask(-val, width), width);
|
|
32598
|
+
}
|
|
32599
|
+
|
|
32600
|
+
} else {
|
|
32601
|
+
const masked = mask(val, width);
|
|
32602
|
+
assert(safeOp == null || (val >= 0 && val === masked), "overflow", "NUMERIC_FAULT", {
|
|
32603
|
+
operation: <string>safeOp, fault: "overflow", value: val
|
|
32604
|
+
});
|
|
32605
|
+
val = masked;
|
|
32606
|
+
}
|
|
32607
|
+
*/
|
|
32608
|
+
val = checkValue(val, this.#format, safeOp);
|
|
32609
|
+
return new FixedNumber(_guard$3, val, this.#format);
|
|
32610
|
+
}
|
|
32611
|
+
#add(o, safeOp) {
|
|
32612
|
+
this.#checkFormat(o);
|
|
32613
|
+
return this.#checkValue(this.#val + o.#val, safeOp);
|
|
32614
|
+
}
|
|
32615
|
+
/**
|
|
32616
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% added
|
|
32617
|
+
* to %%other%%, ignoring overflow.
|
|
32618
|
+
*/
|
|
32619
|
+
addUnsafe(other) { return this.#add(other); }
|
|
32620
|
+
/**
|
|
32621
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% added
|
|
32622
|
+
* to %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
32623
|
+
* occurs.
|
|
32624
|
+
*/
|
|
32625
|
+
add(other) { return this.#add(other, "add"); }
|
|
32626
|
+
#sub(o, safeOp) {
|
|
32627
|
+
this.#checkFormat(o);
|
|
32628
|
+
return this.#checkValue(this.#val - o.#val, safeOp);
|
|
32629
|
+
}
|
|
32630
|
+
/**
|
|
32631
|
+
* Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
|
32632
|
+
* from %%this%%, ignoring overflow.
|
|
32633
|
+
*/
|
|
32634
|
+
subUnsafe(other) { return this.#sub(other); }
|
|
32635
|
+
/**
|
|
32636
|
+
* Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
|
32637
|
+
* from %%this%%. A [[NumericFaultError]] is thrown if overflow
|
|
32638
|
+
* occurs.
|
|
32639
|
+
*/
|
|
32640
|
+
sub(other) { return this.#sub(other, "sub"); }
|
|
32641
|
+
#mul(o, safeOp) {
|
|
32642
|
+
this.#checkFormat(o);
|
|
32643
|
+
return this.#checkValue((this.#val * o.#val) / this.#tens, safeOp);
|
|
32644
|
+
}
|
|
32645
|
+
/**
|
|
32646
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
32647
|
+
* by %%other%%, ignoring overflow and underflow (precision loss).
|
|
32648
|
+
*/
|
|
32649
|
+
mulUnsafe(other) { return this.#mul(other); }
|
|
32650
|
+
/**
|
|
32651
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
32652
|
+
* by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
32653
|
+
* occurs.
|
|
32654
|
+
*/
|
|
32655
|
+
mul(other) { return this.#mul(other, "mul"); }
|
|
32656
|
+
/**
|
|
32657
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
32658
|
+
* by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
32659
|
+
* occurs or if underflow (precision loss) occurs.
|
|
32660
|
+
*/
|
|
32661
|
+
mulSignal(other) {
|
|
32662
|
+
this.#checkFormat(other);
|
|
32663
|
+
const value = this.#val * other.#val;
|
|
32664
|
+
assert$2((value % this.#tens) === BN_0$8, "precision lost during signalling mul", "NUMERIC_FAULT", {
|
|
32665
|
+
operation: "mulSignal", fault: "underflow", value: this
|
|
32666
|
+
});
|
|
32667
|
+
return this.#checkValue(value / this.#tens, "mulSignal");
|
|
32668
|
+
}
|
|
32669
|
+
#div(o, safeOp) {
|
|
32670
|
+
assert$2(o.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
|
|
32671
|
+
operation: "div", fault: "divide-by-zero", value: this
|
|
32672
|
+
});
|
|
32673
|
+
this.#checkFormat(o);
|
|
32674
|
+
return this.#checkValue((this.#val * this.#tens) / o.#val, safeOp);
|
|
32675
|
+
}
|
|
32676
|
+
/**
|
|
32677
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
32678
|
+
* by %%other%%, ignoring underflow (precision loss). A
|
|
32679
|
+
* [[NumericFaultError]] is thrown if overflow occurs.
|
|
32680
|
+
*/
|
|
32681
|
+
divUnsafe(other) { return this.#div(other); }
|
|
32682
|
+
/**
|
|
32683
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
32684
|
+
* by %%other%%, ignoring underflow (precision loss). A
|
|
32685
|
+
* [[NumericFaultError]] is thrown if overflow occurs.
|
|
32686
|
+
*/
|
|
32687
|
+
div(other) { return this.#div(other, "div"); }
|
|
32688
|
+
/**
|
|
32689
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
32690
|
+
* by %%other%%. A [[NumericFaultError]] is thrown if underflow
|
|
32691
|
+
* (precision loss) occurs.
|
|
32692
|
+
*/
|
|
32693
|
+
divSignal(other) {
|
|
32694
|
+
assert$2(other.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
|
|
32695
|
+
operation: "div", fault: "divide-by-zero", value: this
|
|
32696
|
+
});
|
|
32697
|
+
this.#checkFormat(other);
|
|
32698
|
+
const value = (this.#val * this.#tens);
|
|
32699
|
+
assert$2((value % other.#val) === BN_0$8, "precision lost during signalling div", "NUMERIC_FAULT", {
|
|
32700
|
+
operation: "divSignal", fault: "underflow", value: this
|
|
32701
|
+
});
|
|
32702
|
+
return this.#checkValue(value / other.#val, "divSignal");
|
|
32703
|
+
}
|
|
32704
|
+
/**
|
|
32705
|
+
* Returns a comparison result between %%this%% and %%other%%.
|
|
32706
|
+
*
|
|
32707
|
+
* This is suitable for use in sorting, where ``-1`` implies %%this%%
|
|
32708
|
+
* is smaller, ``1`` implies %%this%% is larger and ``0`` implies
|
|
32709
|
+
* both are equal.
|
|
32710
|
+
*/
|
|
32711
|
+
cmp(other) {
|
|
32712
|
+
let a = this.value, b = other.value;
|
|
32713
|
+
// Coerce a and b to the same magnitude
|
|
32714
|
+
const delta = this.decimals - other.decimals;
|
|
32715
|
+
if (delta > 0) {
|
|
32716
|
+
b *= getTens(delta);
|
|
32717
|
+
}
|
|
32718
|
+
else if (delta < 0) {
|
|
32719
|
+
a *= getTens(-delta);
|
|
32720
|
+
}
|
|
32721
|
+
// Comnpare
|
|
32722
|
+
if (a < b) {
|
|
32723
|
+
return -1;
|
|
32724
|
+
}
|
|
32725
|
+
if (a > b) {
|
|
32726
|
+
return 1;
|
|
32727
|
+
}
|
|
32728
|
+
return 0;
|
|
32729
|
+
}
|
|
32730
|
+
/**
|
|
32731
|
+
* Returns true if %%other%% is equal to %%this%%.
|
|
32732
|
+
*/
|
|
32733
|
+
eq(other) { return this.cmp(other) === 0; }
|
|
32734
|
+
/**
|
|
32735
|
+
* Returns true if %%other%% is less than to %%this%%.
|
|
32736
|
+
*/
|
|
32737
|
+
lt(other) { return this.cmp(other) < 0; }
|
|
32738
|
+
/**
|
|
32739
|
+
* Returns true if %%other%% is less than or equal to %%this%%.
|
|
32740
|
+
*/
|
|
32741
|
+
lte(other) { return this.cmp(other) <= 0; }
|
|
32742
|
+
/**
|
|
32743
|
+
* Returns true if %%other%% is greater than to %%this%%.
|
|
32744
|
+
*/
|
|
32745
|
+
gt(other) { return this.cmp(other) > 0; }
|
|
32746
|
+
/**
|
|
32747
|
+
* Returns true if %%other%% is greater than or equal to %%this%%.
|
|
32748
|
+
*/
|
|
32749
|
+
gte(other) { return this.cmp(other) >= 0; }
|
|
32750
|
+
/**
|
|
32751
|
+
* Returns a new [[FixedNumber]] which is the largest **integer**
|
|
32752
|
+
* that is less than or equal to %%this%%.
|
|
32753
|
+
*
|
|
32754
|
+
* The decimal component of the result will always be ``0``.
|
|
32755
|
+
*/
|
|
32756
|
+
floor() {
|
|
32757
|
+
let val = this.#val;
|
|
32758
|
+
if (this.#val < BN_0$8) {
|
|
32759
|
+
val -= this.#tens - BN_1$3;
|
|
32760
|
+
}
|
|
32761
|
+
val = (this.#val / this.#tens) * this.#tens;
|
|
32762
|
+
return this.#checkValue(val, "floor");
|
|
32763
|
+
}
|
|
32764
|
+
/**
|
|
32765
|
+
* Returns a new [[FixedNumber]] which is the smallest **integer**
|
|
32766
|
+
* that is greater than or equal to %%this%%.
|
|
32767
|
+
*
|
|
32768
|
+
* The decimal component of the result will always be ``0``.
|
|
32769
|
+
*/
|
|
32770
|
+
ceiling() {
|
|
32771
|
+
let val = this.#val;
|
|
32772
|
+
if (this.#val > BN_0$8) {
|
|
32773
|
+
val += this.#tens - BN_1$3;
|
|
32774
|
+
}
|
|
32775
|
+
val = (this.#val / this.#tens) * this.#tens;
|
|
32776
|
+
return this.#checkValue(val, "ceiling");
|
|
32777
|
+
}
|
|
32778
|
+
/**
|
|
32779
|
+
* Returns a new [[FixedNumber]] with the decimal component
|
|
32780
|
+
* rounded up on ties at %%decimals%% places.
|
|
32781
|
+
*/
|
|
32782
|
+
round(decimals) {
|
|
32783
|
+
if (decimals == null) {
|
|
32784
|
+
decimals = 0;
|
|
32785
|
+
}
|
|
32786
|
+
// Not enough precision to not already be rounded
|
|
32787
|
+
if (decimals >= this.decimals) {
|
|
32788
|
+
return this;
|
|
32789
|
+
}
|
|
32790
|
+
const delta = this.decimals - decimals;
|
|
32791
|
+
const bump = BN_5 * getTens(delta - 1);
|
|
32792
|
+
let value = this.value + bump;
|
|
32793
|
+
const tens = getTens(delta);
|
|
32794
|
+
value = (value / tens) * tens;
|
|
32795
|
+
checkValue(value, this.#format, "round");
|
|
32796
|
+
return new FixedNumber(_guard$3, value, this.#format);
|
|
32797
|
+
}
|
|
32798
|
+
/**
|
|
32799
|
+
* Returns true if %%this%% is equal to ``0``.
|
|
32800
|
+
*/
|
|
32801
|
+
isZero() { return (this.#val === BN_0$8); }
|
|
32802
|
+
/**
|
|
32803
|
+
* Returns true if %%this%% is less than ``0``.
|
|
32804
|
+
*/
|
|
32805
|
+
isNegative() { return (this.#val < BN_0$8); }
|
|
32806
|
+
/**
|
|
32807
|
+
* Returns the string representation of %%this%%.
|
|
32808
|
+
*/
|
|
32809
|
+
toString() { return this._value; }
|
|
32810
|
+
/**
|
|
32811
|
+
* Returns a float approximation.
|
|
32812
|
+
*
|
|
32813
|
+
* Due to IEEE 754 precission (or lack thereof), this function
|
|
32814
|
+
* can only return an approximation and most values will contain
|
|
32815
|
+
* rounding errors.
|
|
32816
|
+
*/
|
|
32817
|
+
toUnsafeFloat() { return parseFloat(this.toString()); }
|
|
32818
|
+
/**
|
|
32819
|
+
* Return a new [[FixedNumber]] with the same value but has had
|
|
32820
|
+
* its field set to %%format%%.
|
|
32821
|
+
*
|
|
32822
|
+
* This will throw if the value cannot fit into %%format%%.
|
|
32823
|
+
*/
|
|
32824
|
+
toFormat(format) {
|
|
32825
|
+
return FixedNumber.fromString(this.toString(), format);
|
|
32826
|
+
}
|
|
32827
|
+
/**
|
|
32828
|
+
* Creates a new [[FixedNumber]] for %%value%% divided by
|
|
32829
|
+
* %%decimal%% places with %%format%%.
|
|
32830
|
+
*
|
|
32831
|
+
* This will throw a [[NumericFaultError]] if %%value%% (once adjusted
|
|
32832
|
+
* for %%decimals%%) cannot fit in %%format%%, either due to overflow
|
|
32833
|
+
* or underflow (precision loss).
|
|
32834
|
+
*/
|
|
32835
|
+
static fromValue(_value, _decimals, _format) {
|
|
32836
|
+
const decimals = (_decimals == null) ? 0 : getNumber(_decimals);
|
|
32837
|
+
const format = getFormat(_format);
|
|
32838
|
+
let value = getBigInt(_value, "value");
|
|
32839
|
+
const delta = decimals - format.decimals;
|
|
32840
|
+
if (delta > 0) {
|
|
32841
|
+
const tens = getTens(delta);
|
|
32842
|
+
assert$2((value % tens) === BN_0$8, "value loses precision for format", "NUMERIC_FAULT", {
|
|
32843
|
+
operation: "fromValue", fault: "underflow", value: _value
|
|
32844
|
+
});
|
|
32845
|
+
value /= tens;
|
|
32846
|
+
}
|
|
32847
|
+
else if (delta < 0) {
|
|
32848
|
+
value *= getTens(-delta);
|
|
32849
|
+
}
|
|
32850
|
+
checkValue(value, format, "fromValue");
|
|
32851
|
+
return new FixedNumber(_guard$3, value, format);
|
|
32852
|
+
}
|
|
32853
|
+
/**
|
|
32854
|
+
* Creates a new [[FixedNumber]] for %%value%% with %%format%%.
|
|
32855
|
+
*
|
|
32856
|
+
* This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
|
32857
|
+
* in %%format%%, either due to overflow or underflow (precision loss).
|
|
32858
|
+
*/
|
|
32859
|
+
static fromString(_value, _format) {
|
|
32860
|
+
const match = _value.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
|
|
32861
|
+
assertArgument(match && (match[2].length + match[3].length) > 0, "invalid FixedNumber string value", "value", _value);
|
|
32862
|
+
const format = getFormat(_format);
|
|
32863
|
+
let whole = (match[2] || "0"), decimal = (match[3] || "");
|
|
32864
|
+
// Pad out the decimals
|
|
32865
|
+
while (decimal.length < format.decimals) {
|
|
32866
|
+
decimal += Zeros$1;
|
|
32867
|
+
}
|
|
32868
|
+
// Check precision is safe
|
|
32869
|
+
assert$2(decimal.substring(format.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
|
|
32870
|
+
operation: "fromString", fault: "underflow", value: _value
|
|
32871
|
+
});
|
|
32872
|
+
// Remove extra padding
|
|
32873
|
+
decimal = decimal.substring(0, format.decimals);
|
|
32874
|
+
const value = BigInt(match[1] + whole + decimal);
|
|
32875
|
+
checkValue(value, format, "fromString");
|
|
32876
|
+
return new FixedNumber(_guard$3, value, format);
|
|
32877
|
+
}
|
|
32878
|
+
/**
|
|
32879
|
+
* Creates a new [[FixedNumber]] with the big-endian representation
|
|
32880
|
+
* %%value%% with %%format%%.
|
|
32881
|
+
*
|
|
32882
|
+
* This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
|
32883
|
+
* in %%format%% due to overflow.
|
|
32884
|
+
*/
|
|
32885
|
+
static fromBytes(_value, _format) {
|
|
32886
|
+
let value = toBigInt(getBytes(_value, "value"));
|
|
32887
|
+
const format = getFormat(_format);
|
|
32888
|
+
if (format.signed) {
|
|
32889
|
+
value = fromTwos(value, format.width);
|
|
32890
|
+
}
|
|
32891
|
+
checkValue(value, format, "fromBytes");
|
|
32892
|
+
return new FixedNumber(_guard$3, value, format);
|
|
32893
|
+
}
|
|
32894
|
+
}
|
|
32895
|
+
//const f1 = FixedNumber.fromString("12.56", "fixed16x2");
|
|
32896
|
+
//const f2 = FixedNumber.fromString("0.3", "fixed16x2");
|
|
32897
|
+
//console.log(f1.divSignal(f2));
|
|
32898
|
+
//const BUMP = FixedNumber.from("0.5");
|
|
32899
|
+
|
|
32293
32900
|
//See: https://github.com/ethereum/wiki/wiki/RLP
|
|
32294
32901
|
function hexlifyByte(value) {
|
|
32295
32902
|
let result = value.toString(16);
|
|
@@ -32414,6 +33021,62 @@ var PolygonIdSdk = (function (exports) {
|
|
|
32414
33021
|
return result;
|
|
32415
33022
|
}
|
|
32416
33023
|
|
|
33024
|
+
/**
|
|
33025
|
+
* Most interactions with Ethereum requires integer values, which use
|
|
33026
|
+
* the smallest magnitude unit.
|
|
33027
|
+
*
|
|
33028
|
+
* For example, imagine dealing with dollars and cents. Since dollars
|
|
33029
|
+
* are divisible, non-integer values are possible, such as ``$10.77``.
|
|
33030
|
+
* By using the smallest indivisible unit (i.e. cents), the value can
|
|
33031
|
+
* be kept as the integer ``1077``.
|
|
33032
|
+
*
|
|
33033
|
+
* When receiving decimal input from the user (as a decimal string),
|
|
33034
|
+
* the value should be converted to an integer and when showing a user
|
|
33035
|
+
* a value, the integer value should be converted to a decimal string.
|
|
33036
|
+
*
|
|
33037
|
+
* This creates a clear distinction, between values to be used by code
|
|
33038
|
+
* (integers) and values used for display logic to users (decimals).
|
|
33039
|
+
*
|
|
33040
|
+
* The native unit in Ethereum, //ether// is divisible to 18 decimal places,
|
|
33041
|
+
* where each individual unit is called a //wei//.
|
|
33042
|
+
*
|
|
33043
|
+
* @_subsection api/utils:Unit Conversion [about-units]
|
|
33044
|
+
*/
|
|
33045
|
+
const names = [
|
|
33046
|
+
"wei",
|
|
33047
|
+
"kwei",
|
|
33048
|
+
"mwei",
|
|
33049
|
+
"gwei",
|
|
33050
|
+
"szabo",
|
|
33051
|
+
"finney",
|
|
33052
|
+
"ether",
|
|
33053
|
+
];
|
|
33054
|
+
/**
|
|
33055
|
+
* Converts the //decimal string// %%value%% to a BigInt, assuming
|
|
33056
|
+
* %%unit%% decimal places. The %%unit%% may the number of decimal places
|
|
33057
|
+
* or the name of a unit (e.g. ``"gwei"`` for 9 decimal places).
|
|
33058
|
+
*/
|
|
33059
|
+
function parseUnits$1(value, unit) {
|
|
33060
|
+
assertArgument(typeof (value) === "string", "value must be a string", "value", value);
|
|
33061
|
+
let decimals = 18;
|
|
33062
|
+
if (typeof (unit) === "string") {
|
|
33063
|
+
const index = names.indexOf(unit);
|
|
33064
|
+
assertArgument(index >= 0, "invalid unit", "unit", unit);
|
|
33065
|
+
decimals = 3 * index;
|
|
33066
|
+
}
|
|
33067
|
+
else if (unit != null) {
|
|
33068
|
+
decimals = getNumber(unit, "unit");
|
|
33069
|
+
}
|
|
33070
|
+
return FixedNumber.fromString(value, { decimals, width: 512 }).value;
|
|
33071
|
+
}
|
|
33072
|
+
/**
|
|
33073
|
+
* Converts the //decimal string// %%ether%% to a BigInt, using 18
|
|
33074
|
+
* decimal places.
|
|
33075
|
+
*/
|
|
33076
|
+
function parseEther(ether) {
|
|
33077
|
+
return parseUnits$1(ether, 18);
|
|
33078
|
+
}
|
|
33079
|
+
|
|
32417
33080
|
/**
|
|
32418
33081
|
* @_ignore:
|
|
32419
33082
|
*/
|
|
@@ -53598,23 +54261,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53598
54261
|
constructor(_configs, _opts) {
|
|
53599
54262
|
this._configs = _configs;
|
|
53600
54263
|
this._opts = _opts;
|
|
53601
|
-
/**
|
|
53602
|
-
* supported circuits
|
|
53603
|
-
*/
|
|
53604
|
-
this._supportedCircuits = [
|
|
53605
|
-
exports.CircuitId.AtomicQueryMTPV2OnChain,
|
|
53606
|
-
exports.CircuitId.AtomicQuerySigV2OnChain,
|
|
53607
|
-
exports.CircuitId.AtomicQueryV3OnChain
|
|
53608
|
-
];
|
|
53609
|
-
/**
|
|
53610
|
-
* abi coder to encode/decode structures to solidity bytes
|
|
53611
|
-
*/
|
|
53612
|
-
this._abiCoder = new AbiCoder();
|
|
53613
54264
|
}
|
|
53614
|
-
|
|
53615
|
-
* {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
|
|
53616
|
-
*/
|
|
53617
|
-
async prepareTxArgsSubmitV1(txData, zkProofResponse) {
|
|
54265
|
+
static async prepareTxArgsSubmitV1(txData, zkProofResponse) {
|
|
53618
54266
|
if (txData.method_id.replace('0x', '') !== exports.FunctionSignatures.SubmitZKPResponseV1) {
|
|
53619
54267
|
throw new Error(`prepareTxArgsSubmitV1 function doesn't implement requested method id. Only '0x${exports.FunctionSignatures.SubmitZKPResponseV1}' is supported.`);
|
|
53620
54268
|
}
|
|
@@ -53632,6 +54280,12 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53632
54280
|
];
|
|
53633
54281
|
return payload;
|
|
53634
54282
|
}
|
|
54283
|
+
/**
|
|
54284
|
+
* {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
|
|
54285
|
+
*/
|
|
54286
|
+
async prepareTxArgsSubmitV1(txData, zkProofResponse) {
|
|
54287
|
+
return OnChainZKPVerifier.prepareTxArgsSubmitV1(txData, zkProofResponse);
|
|
54288
|
+
}
|
|
53635
54289
|
/**
|
|
53636
54290
|
* {@inheritDoc IOnChainZKPVerifier.submitZKPResponse}
|
|
53637
54291
|
*/
|
|
@@ -53721,13 +54375,10 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53721
54375
|
const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
|
|
53722
54376
|
return new Map().set(txnHash, zkProofResponses);
|
|
53723
54377
|
}
|
|
53724
|
-
async prepareTxArgsSubmitV2(txData, zkProofResponses) {
|
|
54378
|
+
static async prepareTxArgsSubmitV2(resolverUrl, txData, zkProofResponses) {
|
|
53725
54379
|
if (txData.method_id.replace('0x', '') !== exports.FunctionSignatures.SubmitZKPResponseV2) {
|
|
53726
54380
|
throw new Error(`submit cross chain doesn't implement requested method id. Only '0x${exports.FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
|
|
53727
54381
|
}
|
|
53728
|
-
if (!this._opts?.didResolverUrl) {
|
|
53729
|
-
throw new Error(`did resolver url required for crosschain verification`);
|
|
53730
|
-
}
|
|
53731
54382
|
const gistUpdateArr = [];
|
|
53732
54383
|
const stateUpdateArr = [];
|
|
53733
54384
|
const payload = [];
|
|
@@ -53752,7 +54403,9 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53752
54403
|
continue;
|
|
53753
54404
|
}
|
|
53754
54405
|
gistUpdateResolutionsPending.push(JSON.stringify(gist));
|
|
53755
|
-
gistUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(Q$2.parseFromId(gist.id),
|
|
54406
|
+
gistUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(Q$2.parseFromId(gist.id), resolverUrl, {
|
|
54407
|
+
gist: gist.root
|
|
54408
|
+
}));
|
|
53756
54409
|
}
|
|
53757
54410
|
const stateUpdateResolutions = [];
|
|
53758
54411
|
for (const state of stateInfo.states) {
|
|
@@ -53761,7 +54414,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53761
54414
|
continue;
|
|
53762
54415
|
}
|
|
53763
54416
|
stateUpdateResolutionsPending.push(JSON.stringify(state));
|
|
53764
|
-
stateUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(Q$2.parseFromId(state.id),
|
|
54417
|
+
stateUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(Q$2.parseFromId(state.id), resolverUrl, {
|
|
53765
54418
|
state: state.state
|
|
53766
54419
|
}));
|
|
53767
54420
|
}
|
|
@@ -53795,10 +54448,16 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53795
54448
|
const crossChainProofs = this.packCrossChainProofs(gistUpdateArr, stateUpdateArr);
|
|
53796
54449
|
return [payload, crossChainProofs];
|
|
53797
54450
|
}
|
|
53798
|
-
|
|
53799
|
-
|
|
54451
|
+
async prepareTxArgsSubmitV2(txData, zkProofResponses) {
|
|
54452
|
+
if (!this._opts?.didResolverUrl) {
|
|
54453
|
+
throw new Error(`did resolver url required for crosschain verification`);
|
|
54454
|
+
}
|
|
54455
|
+
return OnChainZKPVerifier.prepareTxArgsSubmitV2(this._opts.didResolverUrl, txData, zkProofResponses);
|
|
54456
|
+
}
|
|
54457
|
+
static packZkpProof(inputs, a, b, c) {
|
|
54458
|
+
return new AbiCoder().encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
|
|
53800
54459
|
}
|
|
53801
|
-
packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
|
|
54460
|
+
static packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
|
|
53802
54461
|
const proofs = [];
|
|
53803
54462
|
for (const globalStateUpdate of gistUpdateArr) {
|
|
53804
54463
|
proofs.push({
|
|
@@ -53812,10 +54471,10 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53812
54471
|
proof: this.packIdentityStateMsg(stateUpdate)
|
|
53813
54472
|
});
|
|
53814
54473
|
}
|
|
53815
|
-
return
|
|
54474
|
+
return new AbiCoder().encode(['tuple(' + 'string proofType,' + 'bytes proof' + ')[]'], [proofs]);
|
|
53816
54475
|
}
|
|
53817
|
-
packGlobalStateMsg(msg) {
|
|
53818
|
-
return
|
|
54476
|
+
static packGlobalStateMsg(msg) {
|
|
54477
|
+
return new AbiCoder().encode([
|
|
53819
54478
|
'tuple(' +
|
|
53820
54479
|
'tuple(' +
|
|
53821
54480
|
'uint256 timestamp,' +
|
|
@@ -53827,8 +54486,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53827
54486
|
')'
|
|
53828
54487
|
], [msg]);
|
|
53829
54488
|
}
|
|
53830
|
-
packIdentityStateMsg(msg) {
|
|
53831
|
-
return
|
|
54489
|
+
static packIdentityStateMsg(msg) {
|
|
54490
|
+
return new AbiCoder().encode([
|
|
53832
54491
|
'tuple(' +
|
|
53833
54492
|
'tuple(' +
|
|
53834
54493
|
'uint256 timestamp,' +
|
|
@@ -53840,10 +54499,10 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53840
54499
|
')'
|
|
53841
54500
|
], [msg]);
|
|
53842
54501
|
}
|
|
53843
|
-
packMetadatas(metas) {
|
|
53844
|
-
return
|
|
54502
|
+
static packMetadatas(metas) {
|
|
54503
|
+
return new AbiCoder().encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
|
|
53845
54504
|
}
|
|
53846
|
-
getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
|
|
54505
|
+
static getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
|
|
53847
54506
|
let atomicQueryPubSignals;
|
|
53848
54507
|
switch (onChainCircuitId) {
|
|
53849
54508
|
case exports.CircuitId.AtomicQueryMTPV2OnChain:
|
|
@@ -53860,7 +54519,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53860
54519
|
atomicQueryPubSignals.pubSignalsUnmarshal(encodedInputs);
|
|
53861
54520
|
return atomicQueryPubSignals.getStatesInfo();
|
|
53862
54521
|
}
|
|
53863
|
-
async resolveDidDocumentEip712MessageAndSignature(did, resolverUrl, opts) {
|
|
54522
|
+
static async resolveDidDocumentEip712MessageAndSignature(did, resolverUrl, opts) {
|
|
53864
54523
|
const didDoc = await resolveDidDocument(did, resolverUrl, {
|
|
53865
54524
|
...opts,
|
|
53866
54525
|
signature: exports.DIDDocumentSignature.EthereumEip712Signature2021
|
|
@@ -53893,6 +54552,14 @@ var PolygonIdSdk = (function (exports) {
|
|
|
53893
54552
|
};
|
|
53894
54553
|
}
|
|
53895
54554
|
}
|
|
54555
|
+
/**
|
|
54556
|
+
* supported circuits
|
|
54557
|
+
*/
|
|
54558
|
+
OnChainZKPVerifier._supportedCircuits = [
|
|
54559
|
+
exports.CircuitId.AtomicQueryMTPV2OnChain,
|
|
54560
|
+
exports.CircuitId.AtomicQuerySigV2OnChain,
|
|
54561
|
+
exports.CircuitId.AtomicQueryV3OnChain
|
|
54562
|
+
];
|
|
53896
54563
|
|
|
53897
54564
|
var abi$1 = [
|
|
53898
54565
|
{
|
|
@@ -54266,31 +54933,2279 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54266
54933
|
var abi = [
|
|
54267
54934
|
{
|
|
54268
54935
|
inputs: [
|
|
54936
|
+
{
|
|
54937
|
+
internalType: "uint256",
|
|
54938
|
+
name: "_userId",
|
|
54939
|
+
type: "uint256"
|
|
54940
|
+
},
|
|
54941
|
+
{
|
|
54942
|
+
internalType: "uint256",
|
|
54943
|
+
name: "_credentialId",
|
|
54944
|
+
type: "uint256"
|
|
54945
|
+
}
|
|
54269
54946
|
],
|
|
54270
|
-
name: "
|
|
54271
|
-
|
|
54947
|
+
name: "getCredential",
|
|
54948
|
+
outputs: [
|
|
54949
|
+
{
|
|
54950
|
+
components: [
|
|
54951
|
+
{
|
|
54952
|
+
internalType: "uint256",
|
|
54953
|
+
name: "id",
|
|
54954
|
+
type: "uint256"
|
|
54955
|
+
},
|
|
54956
|
+
{
|
|
54957
|
+
internalType: "string[]",
|
|
54958
|
+
name: "context",
|
|
54959
|
+
type: "string[]"
|
|
54960
|
+
},
|
|
54961
|
+
{
|
|
54962
|
+
internalType: "string",
|
|
54963
|
+
name: "_type",
|
|
54964
|
+
type: "string"
|
|
54965
|
+
},
|
|
54966
|
+
{
|
|
54967
|
+
internalType: "uint64",
|
|
54968
|
+
name: "issuanceDate",
|
|
54969
|
+
type: "uint64"
|
|
54970
|
+
},
|
|
54971
|
+
{
|
|
54972
|
+
components: [
|
|
54973
|
+
{
|
|
54974
|
+
internalType: "string",
|
|
54975
|
+
name: "id",
|
|
54976
|
+
type: "string"
|
|
54977
|
+
},
|
|
54978
|
+
{
|
|
54979
|
+
internalType: "string",
|
|
54980
|
+
name: "_type",
|
|
54981
|
+
type: "string"
|
|
54982
|
+
}
|
|
54983
|
+
],
|
|
54984
|
+
internalType: "struct INonMerklizedIssuer.CredentialSchema",
|
|
54985
|
+
name: "credentialSchema",
|
|
54986
|
+
type: "tuple"
|
|
54987
|
+
},
|
|
54988
|
+
{
|
|
54989
|
+
components: [
|
|
54990
|
+
{
|
|
54991
|
+
internalType: "string",
|
|
54992
|
+
name: "id",
|
|
54993
|
+
type: "string"
|
|
54994
|
+
},
|
|
54995
|
+
{
|
|
54996
|
+
internalType: "string",
|
|
54997
|
+
name: "_type",
|
|
54998
|
+
type: "string"
|
|
54999
|
+
}
|
|
55000
|
+
],
|
|
55001
|
+
internalType: "struct INonMerklizedIssuer.DisplayMethod",
|
|
55002
|
+
name: "displayMethod",
|
|
55003
|
+
type: "tuple"
|
|
55004
|
+
}
|
|
55005
|
+
],
|
|
55006
|
+
internalType: "struct INonMerklizedIssuer.CredentialData",
|
|
55007
|
+
name: "",
|
|
55008
|
+
type: "tuple"
|
|
55009
|
+
},
|
|
55010
|
+
{
|
|
55011
|
+
internalType: "uint256[8]",
|
|
55012
|
+
name: "",
|
|
55013
|
+
type: "uint256[8]"
|
|
55014
|
+
},
|
|
55015
|
+
{
|
|
55016
|
+
components: [
|
|
55017
|
+
{
|
|
55018
|
+
internalType: "string",
|
|
55019
|
+
name: "key",
|
|
55020
|
+
type: "string"
|
|
55021
|
+
},
|
|
55022
|
+
{
|
|
55023
|
+
internalType: "uint256",
|
|
55024
|
+
name: "value",
|
|
55025
|
+
type: "uint256"
|
|
55026
|
+
},
|
|
55027
|
+
{
|
|
55028
|
+
internalType: "bytes",
|
|
55029
|
+
name: "rawValue",
|
|
55030
|
+
type: "bytes"
|
|
55031
|
+
}
|
|
55032
|
+
],
|
|
55033
|
+
internalType: "struct INonMerklizedIssuer.SubjectField[]",
|
|
55034
|
+
name: "",
|
|
55035
|
+
type: "tuple[]"
|
|
55036
|
+
}
|
|
55037
|
+
],
|
|
55038
|
+
stateMutability: "view",
|
|
55039
|
+
type: "function"
|
|
54272
55040
|
},
|
|
54273
55041
|
{
|
|
54274
55042
|
inputs: [
|
|
55043
|
+
],
|
|
55044
|
+
name: "getCredentialAdapterVersion",
|
|
55045
|
+
outputs: [
|
|
54275
55046
|
{
|
|
54276
|
-
internalType: "
|
|
54277
|
-
name: "
|
|
54278
|
-
type: "
|
|
55047
|
+
internalType: "string",
|
|
55048
|
+
name: "",
|
|
55049
|
+
type: "string"
|
|
54279
55050
|
}
|
|
54280
55051
|
],
|
|
54281
|
-
|
|
54282
|
-
type: "
|
|
55052
|
+
stateMutability: "view",
|
|
55053
|
+
type: "function"
|
|
54283
55054
|
},
|
|
54284
55055
|
{
|
|
54285
55056
|
inputs: [
|
|
54286
55057
|
{
|
|
54287
|
-
internalType: "
|
|
54288
|
-
name: "
|
|
54289
|
-
type: "
|
|
55058
|
+
internalType: "uint256",
|
|
55059
|
+
name: "_userId",
|
|
55060
|
+
type: "uint256"
|
|
54290
55061
|
}
|
|
54291
55062
|
],
|
|
54292
|
-
name: "
|
|
54293
|
-
|
|
55063
|
+
name: "getUserCredentialIds",
|
|
55064
|
+
outputs: [
|
|
55065
|
+
{
|
|
55066
|
+
internalType: "uint256[]",
|
|
55067
|
+
name: "",
|
|
55068
|
+
type: "uint256[]"
|
|
55069
|
+
}
|
|
55070
|
+
],
|
|
55071
|
+
stateMutability: "view",
|
|
55072
|
+
type: "function"
|
|
55073
|
+
}
|
|
55074
|
+
];
|
|
55075
|
+
|
|
55076
|
+
/* Autogenerated file. Do not edit manually. */
|
|
55077
|
+
/* tslint:disable */
|
|
55078
|
+
/* eslint-disable */
|
|
55079
|
+
const _abi = [
|
|
55080
|
+
{
|
|
55081
|
+
inputs: [],
|
|
55082
|
+
name: 'CREDENTIAL_ADAPTER_VERSION',
|
|
55083
|
+
outputs: [
|
|
55084
|
+
{
|
|
55085
|
+
internalType: 'string',
|
|
55086
|
+
name: '',
|
|
55087
|
+
type: 'string'
|
|
55088
|
+
}
|
|
55089
|
+
],
|
|
55090
|
+
stateMutability: 'view',
|
|
55091
|
+
type: 'function'
|
|
55092
|
+
},
|
|
55093
|
+
{
|
|
55094
|
+
inputs: [
|
|
55095
|
+
{
|
|
55096
|
+
internalType: 'uint256',
|
|
55097
|
+
name: 'claimIndexHash',
|
|
55098
|
+
type: 'uint256'
|
|
55099
|
+
}
|
|
55100
|
+
],
|
|
55101
|
+
name: 'getClaimProof',
|
|
55102
|
+
outputs: [
|
|
55103
|
+
{
|
|
55104
|
+
components: [
|
|
55105
|
+
{
|
|
55106
|
+
internalType: 'uint256',
|
|
55107
|
+
name: 'root',
|
|
55108
|
+
type: 'uint256'
|
|
55109
|
+
},
|
|
55110
|
+
{
|
|
55111
|
+
internalType: 'bool',
|
|
55112
|
+
name: 'existence',
|
|
55113
|
+
type: 'bool'
|
|
55114
|
+
},
|
|
55115
|
+
{
|
|
55116
|
+
internalType: 'uint256[]',
|
|
55117
|
+
name: 'siblings',
|
|
55118
|
+
type: 'uint256[]'
|
|
55119
|
+
},
|
|
55120
|
+
{
|
|
55121
|
+
internalType: 'uint256',
|
|
55122
|
+
name: 'index',
|
|
55123
|
+
type: 'uint256'
|
|
55124
|
+
},
|
|
55125
|
+
{
|
|
55126
|
+
internalType: 'uint256',
|
|
55127
|
+
name: 'value',
|
|
55128
|
+
type: 'uint256'
|
|
55129
|
+
},
|
|
55130
|
+
{
|
|
55131
|
+
internalType: 'bool',
|
|
55132
|
+
name: 'auxExistence',
|
|
55133
|
+
type: 'bool'
|
|
55134
|
+
},
|
|
55135
|
+
{
|
|
55136
|
+
internalType: 'uint256',
|
|
55137
|
+
name: 'auxIndex',
|
|
55138
|
+
type: 'uint256'
|
|
55139
|
+
},
|
|
55140
|
+
{
|
|
55141
|
+
internalType: 'uint256',
|
|
55142
|
+
name: 'auxValue',
|
|
55143
|
+
type: 'uint256'
|
|
55144
|
+
}
|
|
55145
|
+
],
|
|
55146
|
+
internalType: 'struct SmtLib.Proof',
|
|
55147
|
+
name: '',
|
|
55148
|
+
type: 'tuple'
|
|
55149
|
+
}
|
|
55150
|
+
],
|
|
55151
|
+
stateMutability: 'view',
|
|
55152
|
+
type: 'function'
|
|
55153
|
+
},
|
|
55154
|
+
{
|
|
55155
|
+
inputs: [
|
|
55156
|
+
{
|
|
55157
|
+
internalType: 'uint256',
|
|
55158
|
+
name: 'claimIndexHash',
|
|
55159
|
+
type: 'uint256'
|
|
55160
|
+
},
|
|
55161
|
+
{
|
|
55162
|
+
internalType: 'uint256',
|
|
55163
|
+
name: 'root',
|
|
55164
|
+
type: 'uint256'
|
|
55165
|
+
}
|
|
55166
|
+
],
|
|
55167
|
+
name: 'getClaimProofByRoot',
|
|
55168
|
+
outputs: [
|
|
55169
|
+
{
|
|
55170
|
+
components: [
|
|
55171
|
+
{
|
|
55172
|
+
internalType: 'uint256',
|
|
55173
|
+
name: 'root',
|
|
55174
|
+
type: 'uint256'
|
|
55175
|
+
},
|
|
55176
|
+
{
|
|
55177
|
+
internalType: 'bool',
|
|
55178
|
+
name: 'existence',
|
|
55179
|
+
type: 'bool'
|
|
55180
|
+
},
|
|
55181
|
+
{
|
|
55182
|
+
internalType: 'uint256[]',
|
|
55183
|
+
name: 'siblings',
|
|
55184
|
+
type: 'uint256[]'
|
|
55185
|
+
},
|
|
55186
|
+
{
|
|
55187
|
+
internalType: 'uint256',
|
|
55188
|
+
name: 'index',
|
|
55189
|
+
type: 'uint256'
|
|
55190
|
+
},
|
|
55191
|
+
{
|
|
55192
|
+
internalType: 'uint256',
|
|
55193
|
+
name: 'value',
|
|
55194
|
+
type: 'uint256'
|
|
55195
|
+
},
|
|
55196
|
+
{
|
|
55197
|
+
internalType: 'bool',
|
|
55198
|
+
name: 'auxExistence',
|
|
55199
|
+
type: 'bool'
|
|
55200
|
+
},
|
|
55201
|
+
{
|
|
55202
|
+
internalType: 'uint256',
|
|
55203
|
+
name: 'auxIndex',
|
|
55204
|
+
type: 'uint256'
|
|
55205
|
+
},
|
|
55206
|
+
{
|
|
55207
|
+
internalType: 'uint256',
|
|
55208
|
+
name: 'auxValue',
|
|
55209
|
+
type: 'uint256'
|
|
55210
|
+
}
|
|
55211
|
+
],
|
|
55212
|
+
internalType: 'struct SmtLib.Proof',
|
|
55213
|
+
name: '',
|
|
55214
|
+
type: 'tuple'
|
|
55215
|
+
}
|
|
55216
|
+
],
|
|
55217
|
+
stateMutability: 'view',
|
|
55218
|
+
type: 'function'
|
|
55219
|
+
},
|
|
55220
|
+
{
|
|
55221
|
+
inputs: [
|
|
55222
|
+
{
|
|
55223
|
+
internalType: 'uint256',
|
|
55224
|
+
name: 'claimIndexHash',
|
|
55225
|
+
type: 'uint256'
|
|
55226
|
+
}
|
|
55227
|
+
],
|
|
55228
|
+
name: 'getClaimProofWithStateInfo',
|
|
55229
|
+
outputs: [
|
|
55230
|
+
{
|
|
55231
|
+
components: [
|
|
55232
|
+
{
|
|
55233
|
+
internalType: 'uint256',
|
|
55234
|
+
name: 'root',
|
|
55235
|
+
type: 'uint256'
|
|
55236
|
+
},
|
|
55237
|
+
{
|
|
55238
|
+
internalType: 'bool',
|
|
55239
|
+
name: 'existence',
|
|
55240
|
+
type: 'bool'
|
|
55241
|
+
},
|
|
55242
|
+
{
|
|
55243
|
+
internalType: 'uint256[]',
|
|
55244
|
+
name: 'siblings',
|
|
55245
|
+
type: 'uint256[]'
|
|
55246
|
+
},
|
|
55247
|
+
{
|
|
55248
|
+
internalType: 'uint256',
|
|
55249
|
+
name: 'index',
|
|
55250
|
+
type: 'uint256'
|
|
55251
|
+
},
|
|
55252
|
+
{
|
|
55253
|
+
internalType: 'uint256',
|
|
55254
|
+
name: 'value',
|
|
55255
|
+
type: 'uint256'
|
|
55256
|
+
},
|
|
55257
|
+
{
|
|
55258
|
+
internalType: 'bool',
|
|
55259
|
+
name: 'auxExistence',
|
|
55260
|
+
type: 'bool'
|
|
55261
|
+
},
|
|
55262
|
+
{
|
|
55263
|
+
internalType: 'uint256',
|
|
55264
|
+
name: 'auxIndex',
|
|
55265
|
+
type: 'uint256'
|
|
55266
|
+
},
|
|
55267
|
+
{
|
|
55268
|
+
internalType: 'uint256',
|
|
55269
|
+
name: 'auxValue',
|
|
55270
|
+
type: 'uint256'
|
|
55271
|
+
}
|
|
55272
|
+
],
|
|
55273
|
+
internalType: 'struct SmtLib.Proof',
|
|
55274
|
+
name: '',
|
|
55275
|
+
type: 'tuple'
|
|
55276
|
+
},
|
|
55277
|
+
{
|
|
55278
|
+
components: [
|
|
55279
|
+
{
|
|
55280
|
+
internalType: 'uint256',
|
|
55281
|
+
name: 'state',
|
|
55282
|
+
type: 'uint256'
|
|
55283
|
+
},
|
|
55284
|
+
{
|
|
55285
|
+
internalType: 'uint256',
|
|
55286
|
+
name: 'claimsRoot',
|
|
55287
|
+
type: 'uint256'
|
|
55288
|
+
},
|
|
55289
|
+
{
|
|
55290
|
+
internalType: 'uint256',
|
|
55291
|
+
name: 'revocationsRoot',
|
|
55292
|
+
type: 'uint256'
|
|
55293
|
+
},
|
|
55294
|
+
{
|
|
55295
|
+
internalType: 'uint256',
|
|
55296
|
+
name: 'rootsRoot',
|
|
55297
|
+
type: 'uint256'
|
|
55298
|
+
}
|
|
55299
|
+
],
|
|
55300
|
+
internalType: 'struct IdentityLib.StateInfo',
|
|
55301
|
+
name: '',
|
|
55302
|
+
type: 'tuple'
|
|
55303
|
+
}
|
|
55304
|
+
],
|
|
55305
|
+
stateMutability: 'view',
|
|
55306
|
+
type: 'function'
|
|
55307
|
+
},
|
|
55308
|
+
{
|
|
55309
|
+
inputs: [],
|
|
55310
|
+
name: 'getClaimsTreeRoot',
|
|
55311
|
+
outputs: [
|
|
55312
|
+
{
|
|
55313
|
+
internalType: 'uint256',
|
|
55314
|
+
name: '',
|
|
55315
|
+
type: 'uint256'
|
|
55316
|
+
}
|
|
55317
|
+
],
|
|
55318
|
+
stateMutability: 'view',
|
|
55319
|
+
type: 'function'
|
|
55320
|
+
},
|
|
55321
|
+
{
|
|
55322
|
+
inputs: [
|
|
55323
|
+
{
|
|
55324
|
+
internalType: 'uint256',
|
|
55325
|
+
name: '_userId',
|
|
55326
|
+
type: 'uint256'
|
|
55327
|
+
},
|
|
55328
|
+
{
|
|
55329
|
+
internalType: 'uint256',
|
|
55330
|
+
name: '_credentialId',
|
|
55331
|
+
type: 'uint256'
|
|
55332
|
+
}
|
|
55333
|
+
],
|
|
55334
|
+
name: 'getCredential',
|
|
55335
|
+
outputs: [
|
|
55336
|
+
{
|
|
55337
|
+
components: [
|
|
55338
|
+
{
|
|
55339
|
+
internalType: 'uint256',
|
|
55340
|
+
name: 'id',
|
|
55341
|
+
type: 'uint256'
|
|
55342
|
+
},
|
|
55343
|
+
{
|
|
55344
|
+
internalType: 'string[]',
|
|
55345
|
+
name: 'context',
|
|
55346
|
+
type: 'string[]'
|
|
55347
|
+
},
|
|
55348
|
+
{
|
|
55349
|
+
internalType: 'string',
|
|
55350
|
+
name: '_type',
|
|
55351
|
+
type: 'string'
|
|
55352
|
+
},
|
|
55353
|
+
{
|
|
55354
|
+
internalType: 'uint64',
|
|
55355
|
+
name: 'issuanceDate',
|
|
55356
|
+
type: 'uint64'
|
|
55357
|
+
},
|
|
55358
|
+
{
|
|
55359
|
+
components: [
|
|
55360
|
+
{
|
|
55361
|
+
internalType: 'string',
|
|
55362
|
+
name: 'id',
|
|
55363
|
+
type: 'string'
|
|
55364
|
+
},
|
|
55365
|
+
{
|
|
55366
|
+
internalType: 'string',
|
|
55367
|
+
name: '_type',
|
|
55368
|
+
type: 'string'
|
|
55369
|
+
}
|
|
55370
|
+
],
|
|
55371
|
+
internalType: 'struct INonMerklizedIssuer.CredentialSchema',
|
|
55372
|
+
name: 'credentialSchema',
|
|
55373
|
+
type: 'tuple'
|
|
55374
|
+
},
|
|
55375
|
+
{
|
|
55376
|
+
components: [
|
|
55377
|
+
{
|
|
55378
|
+
internalType: 'string',
|
|
55379
|
+
name: 'id',
|
|
55380
|
+
type: 'string'
|
|
55381
|
+
},
|
|
55382
|
+
{
|
|
55383
|
+
internalType: 'string',
|
|
55384
|
+
name: '_type',
|
|
55385
|
+
type: 'string'
|
|
55386
|
+
}
|
|
55387
|
+
],
|
|
55388
|
+
internalType: 'struct INonMerklizedIssuer.DisplayMethod',
|
|
55389
|
+
name: 'displayMethod',
|
|
55390
|
+
type: 'tuple'
|
|
55391
|
+
}
|
|
55392
|
+
],
|
|
55393
|
+
internalType: 'struct INonMerklizedIssuer.CredentialData',
|
|
55394
|
+
name: '',
|
|
55395
|
+
type: 'tuple'
|
|
55396
|
+
},
|
|
55397
|
+
{
|
|
55398
|
+
internalType: 'uint256[8]',
|
|
55399
|
+
name: '',
|
|
55400
|
+
type: 'uint256[8]'
|
|
55401
|
+
},
|
|
55402
|
+
{
|
|
55403
|
+
components: [
|
|
55404
|
+
{
|
|
55405
|
+
internalType: 'string',
|
|
55406
|
+
name: 'key',
|
|
55407
|
+
type: 'string'
|
|
55408
|
+
},
|
|
55409
|
+
{
|
|
55410
|
+
internalType: 'uint256',
|
|
55411
|
+
name: 'value',
|
|
55412
|
+
type: 'uint256'
|
|
55413
|
+
},
|
|
55414
|
+
{
|
|
55415
|
+
internalType: 'bytes',
|
|
55416
|
+
name: 'rawValue',
|
|
55417
|
+
type: 'bytes'
|
|
55418
|
+
}
|
|
55419
|
+
],
|
|
55420
|
+
internalType: 'struct INonMerklizedIssuer.SubjectField[]',
|
|
55421
|
+
name: '',
|
|
55422
|
+
type: 'tuple[]'
|
|
55423
|
+
}
|
|
55424
|
+
],
|
|
55425
|
+
stateMutability: 'view',
|
|
55426
|
+
type: 'function'
|
|
55427
|
+
},
|
|
55428
|
+
{
|
|
55429
|
+
inputs: [],
|
|
55430
|
+
name: 'getCredentialAdapterVersion',
|
|
55431
|
+
outputs: [
|
|
55432
|
+
{
|
|
55433
|
+
internalType: 'string',
|
|
55434
|
+
name: '',
|
|
55435
|
+
type: 'string'
|
|
55436
|
+
}
|
|
55437
|
+
],
|
|
55438
|
+
stateMutability: 'pure',
|
|
55439
|
+
type: 'function'
|
|
55440
|
+
},
|
|
55441
|
+
{
|
|
55442
|
+
inputs: [],
|
|
55443
|
+
name: 'getId',
|
|
55444
|
+
outputs: [
|
|
55445
|
+
{
|
|
55446
|
+
internalType: 'uint256',
|
|
55447
|
+
name: '',
|
|
55448
|
+
type: 'uint256'
|
|
55449
|
+
}
|
|
55450
|
+
],
|
|
55451
|
+
stateMutability: 'view',
|
|
55452
|
+
type: 'function'
|
|
55453
|
+
},
|
|
55454
|
+
{
|
|
55455
|
+
inputs: [],
|
|
55456
|
+
name: 'getIsOldStateGenesis',
|
|
55457
|
+
outputs: [
|
|
55458
|
+
{
|
|
55459
|
+
internalType: 'bool',
|
|
55460
|
+
name: '',
|
|
55461
|
+
type: 'bool'
|
|
55462
|
+
}
|
|
55463
|
+
],
|
|
55464
|
+
stateMutability: 'view',
|
|
55465
|
+
type: 'function'
|
|
55466
|
+
},
|
|
55467
|
+
{
|
|
55468
|
+
inputs: [],
|
|
55469
|
+
name: 'getLatestPublishedClaimsRoot',
|
|
55470
|
+
outputs: [
|
|
55471
|
+
{
|
|
55472
|
+
internalType: 'uint256',
|
|
55473
|
+
name: '',
|
|
55474
|
+
type: 'uint256'
|
|
55475
|
+
}
|
|
55476
|
+
],
|
|
55477
|
+
stateMutability: 'view',
|
|
55478
|
+
type: 'function'
|
|
55479
|
+
},
|
|
55480
|
+
{
|
|
55481
|
+
inputs: [],
|
|
55482
|
+
name: 'getLatestPublishedRevocationsRoot',
|
|
55483
|
+
outputs: [
|
|
55484
|
+
{
|
|
55485
|
+
internalType: 'uint256',
|
|
55486
|
+
name: '',
|
|
55487
|
+
type: 'uint256'
|
|
55488
|
+
}
|
|
55489
|
+
],
|
|
55490
|
+
stateMutability: 'view',
|
|
55491
|
+
type: 'function'
|
|
55492
|
+
},
|
|
55493
|
+
{
|
|
55494
|
+
inputs: [],
|
|
55495
|
+
name: 'getLatestPublishedRootsRoot',
|
|
55496
|
+
outputs: [
|
|
55497
|
+
{
|
|
55498
|
+
internalType: 'uint256',
|
|
55499
|
+
name: '',
|
|
55500
|
+
type: 'uint256'
|
|
55501
|
+
}
|
|
55502
|
+
],
|
|
55503
|
+
stateMutability: 'view',
|
|
55504
|
+
type: 'function'
|
|
55505
|
+
},
|
|
55506
|
+
{
|
|
55507
|
+
inputs: [],
|
|
55508
|
+
name: 'getLatestPublishedState',
|
|
55509
|
+
outputs: [
|
|
55510
|
+
{
|
|
55511
|
+
internalType: 'uint256',
|
|
55512
|
+
name: '',
|
|
55513
|
+
type: 'uint256'
|
|
55514
|
+
}
|
|
55515
|
+
],
|
|
55516
|
+
stateMutability: 'view',
|
|
55517
|
+
type: 'function'
|
|
55518
|
+
},
|
|
55519
|
+
{
|
|
55520
|
+
inputs: [
|
|
55521
|
+
{
|
|
55522
|
+
internalType: 'uint64',
|
|
55523
|
+
name: 'revocationNonce',
|
|
55524
|
+
type: 'uint64'
|
|
55525
|
+
}
|
|
55526
|
+
],
|
|
55527
|
+
name: 'getRevocationProof',
|
|
55528
|
+
outputs: [
|
|
55529
|
+
{
|
|
55530
|
+
components: [
|
|
55531
|
+
{
|
|
55532
|
+
internalType: 'uint256',
|
|
55533
|
+
name: 'root',
|
|
55534
|
+
type: 'uint256'
|
|
55535
|
+
},
|
|
55536
|
+
{
|
|
55537
|
+
internalType: 'bool',
|
|
55538
|
+
name: 'existence',
|
|
55539
|
+
type: 'bool'
|
|
55540
|
+
},
|
|
55541
|
+
{
|
|
55542
|
+
internalType: 'uint256[]',
|
|
55543
|
+
name: 'siblings',
|
|
55544
|
+
type: 'uint256[]'
|
|
55545
|
+
},
|
|
55546
|
+
{
|
|
55547
|
+
internalType: 'uint256',
|
|
55548
|
+
name: 'index',
|
|
55549
|
+
type: 'uint256'
|
|
55550
|
+
},
|
|
55551
|
+
{
|
|
55552
|
+
internalType: 'uint256',
|
|
55553
|
+
name: 'value',
|
|
55554
|
+
type: 'uint256'
|
|
55555
|
+
},
|
|
55556
|
+
{
|
|
55557
|
+
internalType: 'bool',
|
|
55558
|
+
name: 'auxExistence',
|
|
55559
|
+
type: 'bool'
|
|
55560
|
+
},
|
|
55561
|
+
{
|
|
55562
|
+
internalType: 'uint256',
|
|
55563
|
+
name: 'auxIndex',
|
|
55564
|
+
type: 'uint256'
|
|
55565
|
+
},
|
|
55566
|
+
{
|
|
55567
|
+
internalType: 'uint256',
|
|
55568
|
+
name: 'auxValue',
|
|
55569
|
+
type: 'uint256'
|
|
55570
|
+
}
|
|
55571
|
+
],
|
|
55572
|
+
internalType: 'struct SmtLib.Proof',
|
|
55573
|
+
name: '',
|
|
55574
|
+
type: 'tuple'
|
|
55575
|
+
}
|
|
55576
|
+
],
|
|
55577
|
+
stateMutability: 'view',
|
|
55578
|
+
type: 'function'
|
|
55579
|
+
},
|
|
55580
|
+
{
|
|
55581
|
+
inputs: [
|
|
55582
|
+
{
|
|
55583
|
+
internalType: 'uint64',
|
|
55584
|
+
name: 'revocationNonce',
|
|
55585
|
+
type: 'uint64'
|
|
55586
|
+
},
|
|
55587
|
+
{
|
|
55588
|
+
internalType: 'uint256',
|
|
55589
|
+
name: 'root',
|
|
55590
|
+
type: 'uint256'
|
|
55591
|
+
}
|
|
55592
|
+
],
|
|
55593
|
+
name: 'getRevocationProofByRoot',
|
|
55594
|
+
outputs: [
|
|
55595
|
+
{
|
|
55596
|
+
components: [
|
|
55597
|
+
{
|
|
55598
|
+
internalType: 'uint256',
|
|
55599
|
+
name: 'root',
|
|
55600
|
+
type: 'uint256'
|
|
55601
|
+
},
|
|
55602
|
+
{
|
|
55603
|
+
internalType: 'bool',
|
|
55604
|
+
name: 'existence',
|
|
55605
|
+
type: 'bool'
|
|
55606
|
+
},
|
|
55607
|
+
{
|
|
55608
|
+
internalType: 'uint256[]',
|
|
55609
|
+
name: 'siblings',
|
|
55610
|
+
type: 'uint256[]'
|
|
55611
|
+
},
|
|
55612
|
+
{
|
|
55613
|
+
internalType: 'uint256',
|
|
55614
|
+
name: 'index',
|
|
55615
|
+
type: 'uint256'
|
|
55616
|
+
},
|
|
55617
|
+
{
|
|
55618
|
+
internalType: 'uint256',
|
|
55619
|
+
name: 'value',
|
|
55620
|
+
type: 'uint256'
|
|
55621
|
+
},
|
|
55622
|
+
{
|
|
55623
|
+
internalType: 'bool',
|
|
55624
|
+
name: 'auxExistence',
|
|
55625
|
+
type: 'bool'
|
|
55626
|
+
},
|
|
55627
|
+
{
|
|
55628
|
+
internalType: 'uint256',
|
|
55629
|
+
name: 'auxIndex',
|
|
55630
|
+
type: 'uint256'
|
|
55631
|
+
},
|
|
55632
|
+
{
|
|
55633
|
+
internalType: 'uint256',
|
|
55634
|
+
name: 'auxValue',
|
|
55635
|
+
type: 'uint256'
|
|
55636
|
+
}
|
|
55637
|
+
],
|
|
55638
|
+
internalType: 'struct SmtLib.Proof',
|
|
55639
|
+
name: '',
|
|
55640
|
+
type: 'tuple'
|
|
55641
|
+
}
|
|
55642
|
+
],
|
|
55643
|
+
stateMutability: 'view',
|
|
55644
|
+
type: 'function'
|
|
55645
|
+
},
|
|
55646
|
+
{
|
|
55647
|
+
inputs: [
|
|
55648
|
+
{
|
|
55649
|
+
internalType: 'uint64',
|
|
55650
|
+
name: 'revocationNonce',
|
|
55651
|
+
type: 'uint64'
|
|
55652
|
+
}
|
|
55653
|
+
],
|
|
55654
|
+
name: 'getRevocationProofWithStateInfo',
|
|
55655
|
+
outputs: [
|
|
55656
|
+
{
|
|
55657
|
+
components: [
|
|
55658
|
+
{
|
|
55659
|
+
internalType: 'uint256',
|
|
55660
|
+
name: 'root',
|
|
55661
|
+
type: 'uint256'
|
|
55662
|
+
},
|
|
55663
|
+
{
|
|
55664
|
+
internalType: 'bool',
|
|
55665
|
+
name: 'existence',
|
|
55666
|
+
type: 'bool'
|
|
55667
|
+
},
|
|
55668
|
+
{
|
|
55669
|
+
internalType: 'uint256[]',
|
|
55670
|
+
name: 'siblings',
|
|
55671
|
+
type: 'uint256[]'
|
|
55672
|
+
},
|
|
55673
|
+
{
|
|
55674
|
+
internalType: 'uint256',
|
|
55675
|
+
name: 'index',
|
|
55676
|
+
type: 'uint256'
|
|
55677
|
+
},
|
|
55678
|
+
{
|
|
55679
|
+
internalType: 'uint256',
|
|
55680
|
+
name: 'value',
|
|
55681
|
+
type: 'uint256'
|
|
55682
|
+
},
|
|
55683
|
+
{
|
|
55684
|
+
internalType: 'bool',
|
|
55685
|
+
name: 'auxExistence',
|
|
55686
|
+
type: 'bool'
|
|
55687
|
+
},
|
|
55688
|
+
{
|
|
55689
|
+
internalType: 'uint256',
|
|
55690
|
+
name: 'auxIndex',
|
|
55691
|
+
type: 'uint256'
|
|
55692
|
+
},
|
|
55693
|
+
{
|
|
55694
|
+
internalType: 'uint256',
|
|
55695
|
+
name: 'auxValue',
|
|
55696
|
+
type: 'uint256'
|
|
55697
|
+
}
|
|
55698
|
+
],
|
|
55699
|
+
internalType: 'struct SmtLib.Proof',
|
|
55700
|
+
name: '',
|
|
55701
|
+
type: 'tuple'
|
|
55702
|
+
},
|
|
55703
|
+
{
|
|
55704
|
+
components: [
|
|
55705
|
+
{
|
|
55706
|
+
internalType: 'uint256',
|
|
55707
|
+
name: 'state',
|
|
55708
|
+
type: 'uint256'
|
|
55709
|
+
},
|
|
55710
|
+
{
|
|
55711
|
+
internalType: 'uint256',
|
|
55712
|
+
name: 'claimsRoot',
|
|
55713
|
+
type: 'uint256'
|
|
55714
|
+
},
|
|
55715
|
+
{
|
|
55716
|
+
internalType: 'uint256',
|
|
55717
|
+
name: 'revocationsRoot',
|
|
55718
|
+
type: 'uint256'
|
|
55719
|
+
},
|
|
55720
|
+
{
|
|
55721
|
+
internalType: 'uint256',
|
|
55722
|
+
name: 'rootsRoot',
|
|
55723
|
+
type: 'uint256'
|
|
55724
|
+
}
|
|
55725
|
+
],
|
|
55726
|
+
internalType: 'struct IdentityLib.StateInfo',
|
|
55727
|
+
name: '',
|
|
55728
|
+
type: 'tuple'
|
|
55729
|
+
}
|
|
55730
|
+
],
|
|
55731
|
+
stateMutability: 'view',
|
|
55732
|
+
type: 'function'
|
|
55733
|
+
},
|
|
55734
|
+
{
|
|
55735
|
+
inputs: [
|
|
55736
|
+
{
|
|
55737
|
+
internalType: 'uint256',
|
|
55738
|
+
name: 'id',
|
|
55739
|
+
type: 'uint256'
|
|
55740
|
+
},
|
|
55741
|
+
{
|
|
55742
|
+
internalType: 'uint64',
|
|
55743
|
+
name: 'nonce',
|
|
55744
|
+
type: 'uint64'
|
|
55745
|
+
}
|
|
55746
|
+
],
|
|
55747
|
+
name: 'getRevocationStatus',
|
|
55748
|
+
outputs: [
|
|
55749
|
+
{
|
|
55750
|
+
components: [
|
|
55751
|
+
{
|
|
55752
|
+
components: [
|
|
55753
|
+
{
|
|
55754
|
+
internalType: 'uint256',
|
|
55755
|
+
name: 'state',
|
|
55756
|
+
type: 'uint256'
|
|
55757
|
+
},
|
|
55758
|
+
{
|
|
55759
|
+
internalType: 'uint256',
|
|
55760
|
+
name: 'claimsTreeRoot',
|
|
55761
|
+
type: 'uint256'
|
|
55762
|
+
},
|
|
55763
|
+
{
|
|
55764
|
+
internalType: 'uint256',
|
|
55765
|
+
name: 'revocationTreeRoot',
|
|
55766
|
+
type: 'uint256'
|
|
55767
|
+
},
|
|
55768
|
+
{
|
|
55769
|
+
internalType: 'uint256',
|
|
55770
|
+
name: 'rootOfRoots',
|
|
55771
|
+
type: 'uint256'
|
|
55772
|
+
}
|
|
55773
|
+
],
|
|
55774
|
+
internalType: 'struct IOnchainCredentialStatusResolver.IdentityStateRoots',
|
|
55775
|
+
name: 'issuer',
|
|
55776
|
+
type: 'tuple'
|
|
55777
|
+
},
|
|
55778
|
+
{
|
|
55779
|
+
components: [
|
|
55780
|
+
{
|
|
55781
|
+
internalType: 'uint256',
|
|
55782
|
+
name: 'root',
|
|
55783
|
+
type: 'uint256'
|
|
55784
|
+
},
|
|
55785
|
+
{
|
|
55786
|
+
internalType: 'bool',
|
|
55787
|
+
name: 'existence',
|
|
55788
|
+
type: 'bool'
|
|
55789
|
+
},
|
|
55790
|
+
{
|
|
55791
|
+
internalType: 'uint256[]',
|
|
55792
|
+
name: 'siblings',
|
|
55793
|
+
type: 'uint256[]'
|
|
55794
|
+
},
|
|
55795
|
+
{
|
|
55796
|
+
internalType: 'uint256',
|
|
55797
|
+
name: 'index',
|
|
55798
|
+
type: 'uint256'
|
|
55799
|
+
},
|
|
55800
|
+
{
|
|
55801
|
+
internalType: 'uint256',
|
|
55802
|
+
name: 'value',
|
|
55803
|
+
type: 'uint256'
|
|
55804
|
+
},
|
|
55805
|
+
{
|
|
55806
|
+
internalType: 'bool',
|
|
55807
|
+
name: 'auxExistence',
|
|
55808
|
+
type: 'bool'
|
|
55809
|
+
},
|
|
55810
|
+
{
|
|
55811
|
+
internalType: 'uint256',
|
|
55812
|
+
name: 'auxIndex',
|
|
55813
|
+
type: 'uint256'
|
|
55814
|
+
},
|
|
55815
|
+
{
|
|
55816
|
+
internalType: 'uint256',
|
|
55817
|
+
name: 'auxValue',
|
|
55818
|
+
type: 'uint256'
|
|
55819
|
+
}
|
|
55820
|
+
],
|
|
55821
|
+
internalType: 'struct IOnchainCredentialStatusResolver.Proof',
|
|
55822
|
+
name: 'mtp',
|
|
55823
|
+
type: 'tuple'
|
|
55824
|
+
}
|
|
55825
|
+
],
|
|
55826
|
+
internalType: 'struct IOnchainCredentialStatusResolver.CredentialStatus',
|
|
55827
|
+
name: '',
|
|
55828
|
+
type: 'tuple'
|
|
55829
|
+
}
|
|
55830
|
+
],
|
|
55831
|
+
stateMutability: 'view',
|
|
55832
|
+
type: 'function'
|
|
55833
|
+
},
|
|
55834
|
+
{
|
|
55835
|
+
inputs: [
|
|
55836
|
+
{
|
|
55837
|
+
internalType: 'uint256',
|
|
55838
|
+
name: 'id',
|
|
55839
|
+
type: 'uint256'
|
|
55840
|
+
},
|
|
55841
|
+
{
|
|
55842
|
+
internalType: 'uint256',
|
|
55843
|
+
name: 'state',
|
|
55844
|
+
type: 'uint256'
|
|
55845
|
+
},
|
|
55846
|
+
{
|
|
55847
|
+
internalType: 'uint64',
|
|
55848
|
+
name: 'nonce',
|
|
55849
|
+
type: 'uint64'
|
|
55850
|
+
}
|
|
55851
|
+
],
|
|
55852
|
+
name: 'getRevocationStatusByIdAndState',
|
|
55853
|
+
outputs: [
|
|
55854
|
+
{
|
|
55855
|
+
components: [
|
|
55856
|
+
{
|
|
55857
|
+
components: [
|
|
55858
|
+
{
|
|
55859
|
+
internalType: 'uint256',
|
|
55860
|
+
name: 'state',
|
|
55861
|
+
type: 'uint256'
|
|
55862
|
+
},
|
|
55863
|
+
{
|
|
55864
|
+
internalType: 'uint256',
|
|
55865
|
+
name: 'claimsTreeRoot',
|
|
55866
|
+
type: 'uint256'
|
|
55867
|
+
},
|
|
55868
|
+
{
|
|
55869
|
+
internalType: 'uint256',
|
|
55870
|
+
name: 'revocationTreeRoot',
|
|
55871
|
+
type: 'uint256'
|
|
55872
|
+
},
|
|
55873
|
+
{
|
|
55874
|
+
internalType: 'uint256',
|
|
55875
|
+
name: 'rootOfRoots',
|
|
55876
|
+
type: 'uint256'
|
|
55877
|
+
}
|
|
55878
|
+
],
|
|
55879
|
+
internalType: 'struct IOnchainCredentialStatusResolver.IdentityStateRoots',
|
|
55880
|
+
name: 'issuer',
|
|
55881
|
+
type: 'tuple'
|
|
55882
|
+
},
|
|
55883
|
+
{
|
|
55884
|
+
components: [
|
|
55885
|
+
{
|
|
55886
|
+
internalType: 'uint256',
|
|
55887
|
+
name: 'root',
|
|
55888
|
+
type: 'uint256'
|
|
55889
|
+
},
|
|
55890
|
+
{
|
|
55891
|
+
internalType: 'bool',
|
|
55892
|
+
name: 'existence',
|
|
55893
|
+
type: 'bool'
|
|
55894
|
+
},
|
|
55895
|
+
{
|
|
55896
|
+
internalType: 'uint256[]',
|
|
55897
|
+
name: 'siblings',
|
|
55898
|
+
type: 'uint256[]'
|
|
55899
|
+
},
|
|
55900
|
+
{
|
|
55901
|
+
internalType: 'uint256',
|
|
55902
|
+
name: 'index',
|
|
55903
|
+
type: 'uint256'
|
|
55904
|
+
},
|
|
55905
|
+
{
|
|
55906
|
+
internalType: 'uint256',
|
|
55907
|
+
name: 'value',
|
|
55908
|
+
type: 'uint256'
|
|
55909
|
+
},
|
|
55910
|
+
{
|
|
55911
|
+
internalType: 'bool',
|
|
55912
|
+
name: 'auxExistence',
|
|
55913
|
+
type: 'bool'
|
|
55914
|
+
},
|
|
55915
|
+
{
|
|
55916
|
+
internalType: 'uint256',
|
|
55917
|
+
name: 'auxIndex',
|
|
55918
|
+
type: 'uint256'
|
|
55919
|
+
},
|
|
55920
|
+
{
|
|
55921
|
+
internalType: 'uint256',
|
|
55922
|
+
name: 'auxValue',
|
|
55923
|
+
type: 'uint256'
|
|
55924
|
+
}
|
|
55925
|
+
],
|
|
55926
|
+
internalType: 'struct IOnchainCredentialStatusResolver.Proof',
|
|
55927
|
+
name: 'mtp',
|
|
55928
|
+
type: 'tuple'
|
|
55929
|
+
}
|
|
55930
|
+
],
|
|
55931
|
+
internalType: 'struct IOnchainCredentialStatusResolver.CredentialStatus',
|
|
55932
|
+
name: '',
|
|
55933
|
+
type: 'tuple'
|
|
55934
|
+
}
|
|
55935
|
+
],
|
|
55936
|
+
stateMutability: 'view',
|
|
55937
|
+
type: 'function'
|
|
55938
|
+
},
|
|
55939
|
+
{
|
|
55940
|
+
inputs: [],
|
|
55941
|
+
name: 'getRevocationsTreeRoot',
|
|
55942
|
+
outputs: [
|
|
55943
|
+
{
|
|
55944
|
+
internalType: 'uint256',
|
|
55945
|
+
name: '',
|
|
55946
|
+
type: 'uint256'
|
|
55947
|
+
}
|
|
55948
|
+
],
|
|
55949
|
+
stateMutability: 'view',
|
|
55950
|
+
type: 'function'
|
|
55951
|
+
},
|
|
55952
|
+
{
|
|
55953
|
+
inputs: [
|
|
55954
|
+
{
|
|
55955
|
+
internalType: 'uint256',
|
|
55956
|
+
name: 'rootsTreeRoot',
|
|
55957
|
+
type: 'uint256'
|
|
55958
|
+
}
|
|
55959
|
+
],
|
|
55960
|
+
name: 'getRootProof',
|
|
55961
|
+
outputs: [
|
|
55962
|
+
{
|
|
55963
|
+
components: [
|
|
55964
|
+
{
|
|
55965
|
+
internalType: 'uint256',
|
|
55966
|
+
name: 'root',
|
|
55967
|
+
type: 'uint256'
|
|
55968
|
+
},
|
|
55969
|
+
{
|
|
55970
|
+
internalType: 'bool',
|
|
55971
|
+
name: 'existence',
|
|
55972
|
+
type: 'bool'
|
|
55973
|
+
},
|
|
55974
|
+
{
|
|
55975
|
+
internalType: 'uint256[]',
|
|
55976
|
+
name: 'siblings',
|
|
55977
|
+
type: 'uint256[]'
|
|
55978
|
+
},
|
|
55979
|
+
{
|
|
55980
|
+
internalType: 'uint256',
|
|
55981
|
+
name: 'index',
|
|
55982
|
+
type: 'uint256'
|
|
55983
|
+
},
|
|
55984
|
+
{
|
|
55985
|
+
internalType: 'uint256',
|
|
55986
|
+
name: 'value',
|
|
55987
|
+
type: 'uint256'
|
|
55988
|
+
},
|
|
55989
|
+
{
|
|
55990
|
+
internalType: 'bool',
|
|
55991
|
+
name: 'auxExistence',
|
|
55992
|
+
type: 'bool'
|
|
55993
|
+
},
|
|
55994
|
+
{
|
|
55995
|
+
internalType: 'uint256',
|
|
55996
|
+
name: 'auxIndex',
|
|
55997
|
+
type: 'uint256'
|
|
55998
|
+
},
|
|
55999
|
+
{
|
|
56000
|
+
internalType: 'uint256',
|
|
56001
|
+
name: 'auxValue',
|
|
56002
|
+
type: 'uint256'
|
|
56003
|
+
}
|
|
56004
|
+
],
|
|
56005
|
+
internalType: 'struct SmtLib.Proof',
|
|
56006
|
+
name: '',
|
|
56007
|
+
type: 'tuple'
|
|
56008
|
+
}
|
|
56009
|
+
],
|
|
56010
|
+
stateMutability: 'view',
|
|
56011
|
+
type: 'function'
|
|
56012
|
+
},
|
|
56013
|
+
{
|
|
56014
|
+
inputs: [
|
|
56015
|
+
{
|
|
56016
|
+
internalType: 'uint256',
|
|
56017
|
+
name: 'claimsTreeRoot',
|
|
56018
|
+
type: 'uint256'
|
|
56019
|
+
},
|
|
56020
|
+
{
|
|
56021
|
+
internalType: 'uint256',
|
|
56022
|
+
name: 'root',
|
|
56023
|
+
type: 'uint256'
|
|
56024
|
+
}
|
|
56025
|
+
],
|
|
56026
|
+
name: 'getRootProofByRoot',
|
|
56027
|
+
outputs: [
|
|
56028
|
+
{
|
|
56029
|
+
components: [
|
|
56030
|
+
{
|
|
56031
|
+
internalType: 'uint256',
|
|
56032
|
+
name: 'root',
|
|
56033
|
+
type: 'uint256'
|
|
56034
|
+
},
|
|
56035
|
+
{
|
|
56036
|
+
internalType: 'bool',
|
|
56037
|
+
name: 'existence',
|
|
56038
|
+
type: 'bool'
|
|
56039
|
+
},
|
|
56040
|
+
{
|
|
56041
|
+
internalType: 'uint256[]',
|
|
56042
|
+
name: 'siblings',
|
|
56043
|
+
type: 'uint256[]'
|
|
56044
|
+
},
|
|
56045
|
+
{
|
|
56046
|
+
internalType: 'uint256',
|
|
56047
|
+
name: 'index',
|
|
56048
|
+
type: 'uint256'
|
|
56049
|
+
},
|
|
56050
|
+
{
|
|
56051
|
+
internalType: 'uint256',
|
|
56052
|
+
name: 'value',
|
|
56053
|
+
type: 'uint256'
|
|
56054
|
+
},
|
|
56055
|
+
{
|
|
56056
|
+
internalType: 'bool',
|
|
56057
|
+
name: 'auxExistence',
|
|
56058
|
+
type: 'bool'
|
|
56059
|
+
},
|
|
56060
|
+
{
|
|
56061
|
+
internalType: 'uint256',
|
|
56062
|
+
name: 'auxIndex',
|
|
56063
|
+
type: 'uint256'
|
|
56064
|
+
},
|
|
56065
|
+
{
|
|
56066
|
+
internalType: 'uint256',
|
|
56067
|
+
name: 'auxValue',
|
|
56068
|
+
type: 'uint256'
|
|
56069
|
+
}
|
|
56070
|
+
],
|
|
56071
|
+
internalType: 'struct SmtLib.Proof',
|
|
56072
|
+
name: '',
|
|
56073
|
+
type: 'tuple'
|
|
56074
|
+
}
|
|
56075
|
+
],
|
|
56076
|
+
stateMutability: 'view',
|
|
56077
|
+
type: 'function'
|
|
56078
|
+
},
|
|
56079
|
+
{
|
|
56080
|
+
inputs: [
|
|
56081
|
+
{
|
|
56082
|
+
internalType: 'uint256',
|
|
56083
|
+
name: 'rootsTreeRoot',
|
|
56084
|
+
type: 'uint256'
|
|
56085
|
+
}
|
|
56086
|
+
],
|
|
56087
|
+
name: 'getRootProofWithStateInfo',
|
|
56088
|
+
outputs: [
|
|
56089
|
+
{
|
|
56090
|
+
components: [
|
|
56091
|
+
{
|
|
56092
|
+
internalType: 'uint256',
|
|
56093
|
+
name: 'root',
|
|
56094
|
+
type: 'uint256'
|
|
56095
|
+
},
|
|
56096
|
+
{
|
|
56097
|
+
internalType: 'bool',
|
|
56098
|
+
name: 'existence',
|
|
56099
|
+
type: 'bool'
|
|
56100
|
+
},
|
|
56101
|
+
{
|
|
56102
|
+
internalType: 'uint256[]',
|
|
56103
|
+
name: 'siblings',
|
|
56104
|
+
type: 'uint256[]'
|
|
56105
|
+
},
|
|
56106
|
+
{
|
|
56107
|
+
internalType: 'uint256',
|
|
56108
|
+
name: 'index',
|
|
56109
|
+
type: 'uint256'
|
|
56110
|
+
},
|
|
56111
|
+
{
|
|
56112
|
+
internalType: 'uint256',
|
|
56113
|
+
name: 'value',
|
|
56114
|
+
type: 'uint256'
|
|
56115
|
+
},
|
|
56116
|
+
{
|
|
56117
|
+
internalType: 'bool',
|
|
56118
|
+
name: 'auxExistence',
|
|
56119
|
+
type: 'bool'
|
|
56120
|
+
},
|
|
56121
|
+
{
|
|
56122
|
+
internalType: 'uint256',
|
|
56123
|
+
name: 'auxIndex',
|
|
56124
|
+
type: 'uint256'
|
|
56125
|
+
},
|
|
56126
|
+
{
|
|
56127
|
+
internalType: 'uint256',
|
|
56128
|
+
name: 'auxValue',
|
|
56129
|
+
type: 'uint256'
|
|
56130
|
+
}
|
|
56131
|
+
],
|
|
56132
|
+
internalType: 'struct SmtLib.Proof',
|
|
56133
|
+
name: '',
|
|
56134
|
+
type: 'tuple'
|
|
56135
|
+
},
|
|
56136
|
+
{
|
|
56137
|
+
components: [
|
|
56138
|
+
{
|
|
56139
|
+
internalType: 'uint256',
|
|
56140
|
+
name: 'state',
|
|
56141
|
+
type: 'uint256'
|
|
56142
|
+
},
|
|
56143
|
+
{
|
|
56144
|
+
internalType: 'uint256',
|
|
56145
|
+
name: 'claimsRoot',
|
|
56146
|
+
type: 'uint256'
|
|
56147
|
+
},
|
|
56148
|
+
{
|
|
56149
|
+
internalType: 'uint256',
|
|
56150
|
+
name: 'revocationsRoot',
|
|
56151
|
+
type: 'uint256'
|
|
56152
|
+
},
|
|
56153
|
+
{
|
|
56154
|
+
internalType: 'uint256',
|
|
56155
|
+
name: 'rootsRoot',
|
|
56156
|
+
type: 'uint256'
|
|
56157
|
+
}
|
|
56158
|
+
],
|
|
56159
|
+
internalType: 'struct IdentityLib.StateInfo',
|
|
56160
|
+
name: '',
|
|
56161
|
+
type: 'tuple'
|
|
56162
|
+
}
|
|
56163
|
+
],
|
|
56164
|
+
stateMutability: 'view',
|
|
56165
|
+
type: 'function'
|
|
56166
|
+
},
|
|
56167
|
+
{
|
|
56168
|
+
inputs: [
|
|
56169
|
+
{
|
|
56170
|
+
internalType: 'uint256',
|
|
56171
|
+
name: 'state',
|
|
56172
|
+
type: 'uint256'
|
|
56173
|
+
}
|
|
56174
|
+
],
|
|
56175
|
+
name: 'getRootsByState',
|
|
56176
|
+
outputs: [
|
|
56177
|
+
{
|
|
56178
|
+
components: [
|
|
56179
|
+
{
|
|
56180
|
+
internalType: 'uint256',
|
|
56181
|
+
name: 'claimsRoot',
|
|
56182
|
+
type: 'uint256'
|
|
56183
|
+
},
|
|
56184
|
+
{
|
|
56185
|
+
internalType: 'uint256',
|
|
56186
|
+
name: 'revocationsRoot',
|
|
56187
|
+
type: 'uint256'
|
|
56188
|
+
},
|
|
56189
|
+
{
|
|
56190
|
+
internalType: 'uint256',
|
|
56191
|
+
name: 'rootsRoot',
|
|
56192
|
+
type: 'uint256'
|
|
56193
|
+
}
|
|
56194
|
+
],
|
|
56195
|
+
internalType: 'struct IdentityLib.Roots',
|
|
56196
|
+
name: '',
|
|
56197
|
+
type: 'tuple'
|
|
56198
|
+
}
|
|
56199
|
+
],
|
|
56200
|
+
stateMutability: 'view',
|
|
56201
|
+
type: 'function'
|
|
56202
|
+
},
|
|
56203
|
+
{
|
|
56204
|
+
inputs: [],
|
|
56205
|
+
name: 'getRootsTreeRoot',
|
|
56206
|
+
outputs: [
|
|
56207
|
+
{
|
|
56208
|
+
internalType: 'uint256',
|
|
56209
|
+
name: '',
|
|
56210
|
+
type: 'uint256'
|
|
56211
|
+
}
|
|
56212
|
+
],
|
|
56213
|
+
stateMutability: 'view',
|
|
56214
|
+
type: 'function'
|
|
56215
|
+
},
|
|
56216
|
+
{
|
|
56217
|
+
inputs: [],
|
|
56218
|
+
name: 'getSmtDepth',
|
|
56219
|
+
outputs: [
|
|
56220
|
+
{
|
|
56221
|
+
internalType: 'uint256',
|
|
56222
|
+
name: '',
|
|
56223
|
+
type: 'uint256'
|
|
56224
|
+
}
|
|
56225
|
+
],
|
|
56226
|
+
stateMutability: 'pure',
|
|
56227
|
+
type: 'function'
|
|
56228
|
+
},
|
|
56229
|
+
{
|
|
56230
|
+
inputs: [
|
|
56231
|
+
{
|
|
56232
|
+
internalType: 'uint256',
|
|
56233
|
+
name: '_userId',
|
|
56234
|
+
type: 'uint256'
|
|
56235
|
+
}
|
|
56236
|
+
],
|
|
56237
|
+
name: 'getUserCredentialIds',
|
|
56238
|
+
outputs: [
|
|
56239
|
+
{
|
|
56240
|
+
internalType: 'uint256[]',
|
|
56241
|
+
name: '',
|
|
56242
|
+
type: 'uint256[]'
|
|
56243
|
+
}
|
|
56244
|
+
],
|
|
56245
|
+
stateMutability: 'view',
|
|
56246
|
+
type: 'function'
|
|
56247
|
+
},
|
|
56248
|
+
{
|
|
56249
|
+
inputs: [
|
|
56250
|
+
{
|
|
56251
|
+
internalType: 'address',
|
|
56252
|
+
name: '_stateContractAddr',
|
|
56253
|
+
type: 'address'
|
|
56254
|
+
},
|
|
56255
|
+
{
|
|
56256
|
+
internalType: 'bytes2',
|
|
56257
|
+
name: 'idType',
|
|
56258
|
+
type: 'bytes2'
|
|
56259
|
+
}
|
|
56260
|
+
],
|
|
56261
|
+
name: 'initialize',
|
|
56262
|
+
outputs: [],
|
|
56263
|
+
stateMutability: 'nonpayable',
|
|
56264
|
+
type: 'function'
|
|
56265
|
+
},
|
|
56266
|
+
{
|
|
56267
|
+
inputs: [
|
|
56268
|
+
{
|
|
56269
|
+
internalType: 'bytes4',
|
|
56270
|
+
name: 'interfaceId',
|
|
56271
|
+
type: 'bytes4'
|
|
56272
|
+
}
|
|
56273
|
+
],
|
|
56274
|
+
name: 'supportsInterface',
|
|
56275
|
+
outputs: [
|
|
56276
|
+
{
|
|
56277
|
+
internalType: 'bool',
|
|
56278
|
+
name: '',
|
|
56279
|
+
type: 'bool'
|
|
56280
|
+
}
|
|
56281
|
+
],
|
|
56282
|
+
stateMutability: 'view',
|
|
56283
|
+
type: 'function'
|
|
56284
|
+
}
|
|
56285
|
+
];
|
|
56286
|
+
class NonMerklizedIssuerBase__factory {
|
|
56287
|
+
static abi = _abi;
|
|
56288
|
+
static createInterface() {
|
|
56289
|
+
return new Interface(_abi);
|
|
56290
|
+
}
|
|
56291
|
+
static connect(address, runner) {
|
|
56292
|
+
return new Contract(address, _abi, runner);
|
|
56293
|
+
}
|
|
56294
|
+
}
|
|
56295
|
+
|
|
56296
|
+
var NonMerklizedIssuerInterfaces;
|
|
56297
|
+
(function (NonMerklizedIssuerInterfaces) {
|
|
56298
|
+
NonMerklizedIssuerInterfaces["InterfaceDetection"] = "0x01ffc9a7";
|
|
56299
|
+
NonMerklizedIssuerInterfaces["InterfaceNonMerklizedIssuer"] = "0x58874949";
|
|
56300
|
+
NonMerklizedIssuerInterfaces["InterfaceGetCredential"] = "0x5d1ca631";
|
|
56301
|
+
})(NonMerklizedIssuerInterfaces || (NonMerklizedIssuerInterfaces = {}));
|
|
56302
|
+
var ValueHashes;
|
|
56303
|
+
(function (ValueHashes) {
|
|
56304
|
+
ValueHashes["BooleanTrue"] = "18586133768512220936620570745912940619677854269274689475585506675881198879027";
|
|
56305
|
+
ValueHashes["BooleanFalse"] = "19014214495641488759237505126948346942972912379615652741039992445865937985820";
|
|
56306
|
+
})(ValueHashes || (ValueHashes = {}));
|
|
56307
|
+
/**
|
|
56308
|
+
* `OnchainNonMerklizedIssuerAdapter` provides functionality to interact with a non-merklized on-chain credential issuer.
|
|
56309
|
+
* This adapter enables interface detection, credential retrieval, and conversion to the W3C Verifiable Credential format.
|
|
56310
|
+
*
|
|
56311
|
+
* @public
|
|
56312
|
+
* @beta
|
|
56313
|
+
* @class OnchainNonMerklizedIssuerAdapter
|
|
56314
|
+
*/
|
|
56315
|
+
class OnchainNonMerklizedIssuerAdapter {
|
|
56316
|
+
/**
|
|
56317
|
+
* Initializes an instance of `OnchainNonMerklizedIssuerAdapter`.
|
|
56318
|
+
*
|
|
56319
|
+
* @param ethConnectionConfig The configuration for the Ethereum connection.
|
|
56320
|
+
* @param issuerDid The decentralized identifier (DID) of the issuer.
|
|
56321
|
+
* @param merklizationOptions Optional settings for merklization.
|
|
56322
|
+
*/
|
|
56323
|
+
constructor(ethConnectionConfig, issuerDid, options) {
|
|
56324
|
+
if (!ethConnectionConfig.chainId) {
|
|
56325
|
+
throw new Error('Chain ID is required');
|
|
56326
|
+
}
|
|
56327
|
+
this._chainId = ethConnectionConfig.chainId;
|
|
56328
|
+
this._contractAddress = getAddress(hexlify($$1.ethAddressFromId(Q$2.idFromDID(issuerDid))));
|
|
56329
|
+
this._contract = NonMerklizedIssuerBase__factory.connect(this._contractAddress, new JsonRpcProvider(ethConnectionConfig.url));
|
|
56330
|
+
this._issuerDid = issuerDid;
|
|
56331
|
+
this._merklizationOptions = options?.merklizationOptions;
|
|
56332
|
+
}
|
|
56333
|
+
/**
|
|
56334
|
+
* Checks if the contract supports required interfaces.
|
|
56335
|
+
* Throws an error if any required interface is unsupported.
|
|
56336
|
+
*
|
|
56337
|
+
* @throws Error - If required interfaces are not supported.
|
|
56338
|
+
*/
|
|
56339
|
+
async isInterfaceSupported() {
|
|
56340
|
+
const supportedInterfaces = [
|
|
56341
|
+
{
|
|
56342
|
+
name: 'Interface detection ERC-165',
|
|
56343
|
+
value: NonMerklizedIssuerInterfaces.InterfaceDetection
|
|
56344
|
+
},
|
|
56345
|
+
{
|
|
56346
|
+
name: 'Interface non-merklized issuer',
|
|
56347
|
+
value: NonMerklizedIssuerInterfaces.InterfaceNonMerklizedIssuer
|
|
56348
|
+
},
|
|
56349
|
+
{
|
|
56350
|
+
name: 'Interface get credential',
|
|
56351
|
+
value: NonMerklizedIssuerInterfaces.InterfaceGetCredential
|
|
56352
|
+
}
|
|
56353
|
+
];
|
|
56354
|
+
const unsupportedInterfaces = await Promise.all(supportedInterfaces.map(async (interfaceObj) => {
|
|
56355
|
+
const isSupported = await this._contract.supportsInterface(interfaceObj.value);
|
|
56356
|
+
return isSupported ? null : interfaceObj.name;
|
|
56357
|
+
}));
|
|
56358
|
+
const unsupportedInterfacesFiltered = unsupportedInterfaces.filter((interfaceName) => interfaceName !== null);
|
|
56359
|
+
if (unsupportedInterfacesFiltered.length > 0) {
|
|
56360
|
+
throw new Error(`Unsupported interfaces: ${unsupportedInterfacesFiltered.join(', ')}`);
|
|
56361
|
+
}
|
|
56362
|
+
}
|
|
56363
|
+
/**
|
|
56364
|
+
* Retrieves a credential from the on-chain non-merklized contract.
|
|
56365
|
+
* @param userId The user's core.Id.
|
|
56366
|
+
* @param credentialId The unique identifier of the credential.
|
|
56367
|
+
*/
|
|
56368
|
+
async getCredential(userId, credentialId) {
|
|
56369
|
+
const [credentialData, coreClaimBigInts, credentialSubjectFields] = await this._contract.getCredential(userId.bigInt(), credentialId);
|
|
56370
|
+
return { credentialData, coreClaimBigInts, credentialSubjectFields };
|
|
56371
|
+
}
|
|
56372
|
+
/**
|
|
56373
|
+
* Retrieves the credential IDs of a user.
|
|
56374
|
+
* @param userId The user's core.Id.
|
|
56375
|
+
* @returns An array of credential IDs.
|
|
56376
|
+
*/
|
|
56377
|
+
async getUserCredentialsIds(userId) {
|
|
56378
|
+
return this._contract.getUserCredentialIds(userId.bigInt());
|
|
56379
|
+
}
|
|
56380
|
+
/**
|
|
56381
|
+
* Converts on-chain credential to a verifiable credential.
|
|
56382
|
+
*
|
|
56383
|
+
* @param credentialData Data structure of the credential from the contract.
|
|
56384
|
+
* @param coreClaimBigInts Claim data in bigint format.
|
|
56385
|
+
* @param credentialSubjectFields Subject fields of the credential.
|
|
56386
|
+
*/
|
|
56387
|
+
async convertOnChainInfoToW3CCredential(credentialData, coreClaimBigInts, credentialSubjectFields) {
|
|
56388
|
+
const c = new P$2().unMarshalJson(JSON.stringify(coreClaimBigInts.map((b) => b.toString())));
|
|
56389
|
+
const credentialSubject = await this.convertCredentialSubject(c, credentialData.context, credentialData._type, credentialSubjectFields);
|
|
56390
|
+
const credentialRequest = {
|
|
56391
|
+
id: this.credentialId(credentialData.id),
|
|
56392
|
+
credentialSchema: credentialData.credentialSchema.id,
|
|
56393
|
+
type: credentialData._type,
|
|
56394
|
+
credentialSubject: credentialSubject,
|
|
56395
|
+
expiration: c.getExpirationDate()?.getTime(),
|
|
56396
|
+
displayMethod: this.convertDisplayMethod(credentialData.displayMethod),
|
|
56397
|
+
context: credentialData.context,
|
|
56398
|
+
revocationOpts: {
|
|
56399
|
+
id: this._contractAddress,
|
|
56400
|
+
nonce: Number(c.getRevocationNonce()),
|
|
56401
|
+
type: exports.CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023
|
|
56402
|
+
},
|
|
56403
|
+
issuanceDate: p$3(Number(credentialData.issuanceDate)).getTime()
|
|
56404
|
+
};
|
|
56405
|
+
const existenceProof = await this.existenceProof(c);
|
|
56406
|
+
const w3c = W3CCredential.fromCredentialRequest(this._issuerDid, credentialRequest);
|
|
56407
|
+
w3c.proof = [existenceProof];
|
|
56408
|
+
return w3c;
|
|
56409
|
+
}
|
|
56410
|
+
credentialId(id) {
|
|
56411
|
+
return `urn:iden3:onchain:${this._chainId}:${this._contractAddress}:${id}`;
|
|
56412
|
+
}
|
|
56413
|
+
async convertCredentialSubject(coreClaim, contractContexts, credentialType, credentialSubjectFields) {
|
|
56414
|
+
const contractContextsStr = JSON.stringify({
|
|
56415
|
+
'@context': contractContexts
|
|
56416
|
+
});
|
|
56417
|
+
const credentialSubject = {};
|
|
56418
|
+
for (const f of credentialSubjectFields) {
|
|
56419
|
+
const dataType = await lf.newTypeFromContext(contractContextsStr, `${credentialType}.${f.key}`, this._merklizationOptions);
|
|
56420
|
+
switch (dataType) {
|
|
56421
|
+
case exports.XSDNS.Boolean: {
|
|
56422
|
+
switch (f.rawValue.toString()) {
|
|
56423
|
+
case ValueHashes.BooleanTrue:
|
|
56424
|
+
credentialSubject[f.key] = true;
|
|
56425
|
+
break;
|
|
56426
|
+
case ValueHashes.BooleanFalse:
|
|
56427
|
+
credentialSubject[f.key] = false;
|
|
56428
|
+
break;
|
|
56429
|
+
}
|
|
56430
|
+
break;
|
|
56431
|
+
}
|
|
56432
|
+
case (exports.XSDNS.PositiveInteger):
|
|
56433
|
+
{
|
|
56434
|
+
credentialSubject[f.key] = f.value.toString();
|
|
56435
|
+
break;
|
|
56436
|
+
}
|
|
56437
|
+
case exports.XSDNS.Integer: {
|
|
56438
|
+
credentialSubject[f.key] = Number(f.value);
|
|
56439
|
+
break;
|
|
56440
|
+
}
|
|
56441
|
+
case exports.XSDNS.String: {
|
|
56442
|
+
this.validateSourceValue(dataType, f.value, f.rawValue);
|
|
56443
|
+
credentialSubject[f.key] = f.rawValue;
|
|
56444
|
+
break;
|
|
56445
|
+
}
|
|
56446
|
+
case exports.XSDNS.DateTime: {
|
|
56447
|
+
const timestamp = BigInt(f.rawValue);
|
|
56448
|
+
const sourceTimestamp = p$3(Number(timestamp)).toISOString();
|
|
56449
|
+
this.validateSourceValue(dataType, f.value, sourceTimestamp);
|
|
56450
|
+
credentialSubject[f.key] = sourceTimestamp;
|
|
56451
|
+
break;
|
|
56452
|
+
}
|
|
56453
|
+
case exports.XSDNS.Double: {
|
|
56454
|
+
const rawFloat = Number(f.rawValue);
|
|
56455
|
+
this.validateSourceValue(dataType, f.value, rawFloat);
|
|
56456
|
+
credentialSubject[f.key] = rawFloat;
|
|
56457
|
+
break;
|
|
56458
|
+
}
|
|
56459
|
+
default: {
|
|
56460
|
+
throw new Error(`Unsupported data type ${dataType}`);
|
|
56461
|
+
}
|
|
56462
|
+
}
|
|
56463
|
+
}
|
|
56464
|
+
credentialSubject['type'] = credentialType;
|
|
56465
|
+
const subjectId = coreClaim.getId();
|
|
56466
|
+
const subjectDid = Q$2.parseFromId(subjectId);
|
|
56467
|
+
credentialSubject['id'] = subjectDid.string();
|
|
56468
|
+
return credentialSubject;
|
|
56469
|
+
}
|
|
56470
|
+
async existenceProof(coreClaim) {
|
|
56471
|
+
const [mtpProof, stateInfo] = await this._contract.getClaimProofWithStateInfo(coreClaim.hIndex());
|
|
56472
|
+
if (!mtpProof.existence) {
|
|
56473
|
+
throw new Error('Claim does not exist');
|
|
56474
|
+
}
|
|
56475
|
+
const latestStateHash = V$1.fromBigInt(stateInfo.state);
|
|
56476
|
+
const latestClaimsOfRootHash = V$1.fromBigInt(stateInfo.claimsRoot);
|
|
56477
|
+
const latestRevocationOfRootHash = V$1.fromBigInt(stateInfo.revocationsRoot);
|
|
56478
|
+
const latestRootsOfRootHash = V$1.fromBigInt(stateInfo.rootsRoot);
|
|
56479
|
+
const p = new Kt$1({
|
|
56480
|
+
siblings: mtpProof.siblings.map((s) => V$1.fromBigInt(s)),
|
|
56481
|
+
existence: mtpProof.existence,
|
|
56482
|
+
nodeAux: mtpProof.auxExistence
|
|
56483
|
+
? {
|
|
56484
|
+
key: V$1.fromBigInt(mtpProof.auxIndex),
|
|
56485
|
+
value: V$1.fromBigInt(mtpProof.auxValue)
|
|
56486
|
+
}
|
|
56487
|
+
: undefined
|
|
56488
|
+
});
|
|
56489
|
+
return new Iden3SparseMerkleTreeProof({
|
|
56490
|
+
issuerData: {
|
|
56491
|
+
id: this._issuerDid,
|
|
56492
|
+
state: {
|
|
56493
|
+
value: latestStateHash,
|
|
56494
|
+
claimsTreeRoot: latestClaimsOfRootHash,
|
|
56495
|
+
revocationTreeRoot: latestRevocationOfRootHash,
|
|
56496
|
+
rootOfRoots: latestRootsOfRootHash
|
|
56497
|
+
}
|
|
56498
|
+
},
|
|
56499
|
+
mtp: p,
|
|
56500
|
+
coreClaim: coreClaim
|
|
56501
|
+
});
|
|
56502
|
+
}
|
|
56503
|
+
async validateSourceValue(dataType, originHash, source) {
|
|
56504
|
+
const sourceHash = await ff.hashValue(dataType, source);
|
|
56505
|
+
if (sourceHash !== originHash) {
|
|
56506
|
+
throw new Error(`Invalid source value for ${dataType} type`);
|
|
56507
|
+
}
|
|
56508
|
+
}
|
|
56509
|
+
convertDisplayMethod(onchainDisplayMethod) {
|
|
56510
|
+
if (!onchainDisplayMethod.id || !onchainDisplayMethod._type) {
|
|
56511
|
+
return undefined;
|
|
56512
|
+
}
|
|
56513
|
+
switch (onchainDisplayMethod._type) {
|
|
56514
|
+
case exports.DisplayMethodType.Iden3BasicDisplayMethodV1: {
|
|
56515
|
+
return {
|
|
56516
|
+
id: onchainDisplayMethod.id,
|
|
56517
|
+
type: exports.DisplayMethodType.Iden3BasicDisplayMethodV1
|
|
56518
|
+
};
|
|
56519
|
+
}
|
|
56520
|
+
default: {
|
|
56521
|
+
throw new Error(`Unsupported display method type ${onchainDisplayMethod._type}`);
|
|
56522
|
+
}
|
|
56523
|
+
}
|
|
56524
|
+
}
|
|
56525
|
+
}
|
|
56526
|
+
|
|
56527
|
+
/**
|
|
56528
|
+
* Represents an adapter for interacting with on-chain issuers.
|
|
56529
|
+
*
|
|
56530
|
+
* @public
|
|
56531
|
+
* @beta
|
|
56532
|
+
* @class OnchainIssuer
|
|
56533
|
+
*/
|
|
56534
|
+
class OnchainIssuer {
|
|
56535
|
+
/**
|
|
56536
|
+
* Initializes an instance of `Adapter`.
|
|
56537
|
+
* @param config The configuration for the Ethereum connection.
|
|
56538
|
+
* @param merklizationOptions Optional settings for merklization.
|
|
56539
|
+
*/
|
|
56540
|
+
constructor(config, options) {
|
|
56541
|
+
this._ethConnectionConfig = config;
|
|
56542
|
+
this._onchainIssuerOptions = options;
|
|
56543
|
+
}
|
|
56544
|
+
/**
|
|
56545
|
+
* Retrieves a credential from the on-chain issuer.
|
|
56546
|
+
* @param issuerDID The issuer's core.DID.
|
|
56547
|
+
* @param userId The user's core.Id.
|
|
56548
|
+
* @param credentialId The unique identifier of the credential.
|
|
56549
|
+
*/
|
|
56550
|
+
async getCredential(issuerDID, userDID, credentialId) {
|
|
56551
|
+
const { contract, connection } = this.getContractConnection(issuerDID);
|
|
56552
|
+
const response = await contract.getCredentialAdapterVersion();
|
|
56553
|
+
switch (response) {
|
|
56554
|
+
case '0.0.1': {
|
|
56555
|
+
const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
|
|
56556
|
+
merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
|
|
56557
|
+
});
|
|
56558
|
+
await adapter.isInterfaceSupported();
|
|
56559
|
+
const { credentialData, coreClaimBigInts, credentialSubjectFields } = await adapter.getCredential(Q$2.idFromDID(userDID), credentialId);
|
|
56560
|
+
return await adapter.convertOnChainInfoToW3CCredential(credentialData, coreClaimBigInts, credentialSubjectFields);
|
|
56561
|
+
}
|
|
56562
|
+
default:
|
|
56563
|
+
throw new Error(`Unsupported adapter version ${response}`);
|
|
56564
|
+
}
|
|
56565
|
+
}
|
|
56566
|
+
/**
|
|
56567
|
+
* Retrieves the credential identifiers for a user from the on-chain issuer.
|
|
56568
|
+
* @param issuerDID The issuer's core.DID.
|
|
56569
|
+
* @param userId The user's core.Id.
|
|
56570
|
+
*/
|
|
56571
|
+
async getUserCredentialIds(issuerDID, userDID) {
|
|
56572
|
+
const { contract, connection } = this.getContractConnection(issuerDID);
|
|
56573
|
+
const response = await contract.getCredentialAdapterVersion();
|
|
56574
|
+
switch (response) {
|
|
56575
|
+
case '0.0.1': {
|
|
56576
|
+
const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
|
|
56577
|
+
merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
|
|
56578
|
+
});
|
|
56579
|
+
await adapter.isInterfaceSupported();
|
|
56580
|
+
return await adapter.getUserCredentialsIds(Q$2.idFromDID(userDID));
|
|
56581
|
+
}
|
|
56582
|
+
default:
|
|
56583
|
+
throw new Error(`Unsupported adapter version ${response}`);
|
|
56584
|
+
}
|
|
56585
|
+
}
|
|
56586
|
+
getContractConnection(did) {
|
|
56587
|
+
const issuerId = Q$2.idFromDID(did);
|
|
56588
|
+
const chainId = rt$2(did);
|
|
56589
|
+
const contractAddress = getAddress(hexlify($$1.ethAddressFromId(issuerId)));
|
|
56590
|
+
const connection = this._ethConnectionConfig.find((c) => c.chainId === chainId);
|
|
56591
|
+
if (!connection) {
|
|
56592
|
+
throw new Error(`No connection found for chain ID ${chainId}`);
|
|
56593
|
+
}
|
|
56594
|
+
if (!connection.url) {
|
|
56595
|
+
throw new Error(`No URL found for chain ID ${chainId}`);
|
|
56596
|
+
}
|
|
56597
|
+
const contract = new Contract(contractAddress, abi, new JsonRpcProvider(connection.url));
|
|
56598
|
+
return { contract, connection };
|
|
56599
|
+
}
|
|
56600
|
+
}
|
|
56601
|
+
|
|
56602
|
+
class DidResolverStateReadonlyStorage {
|
|
56603
|
+
constructor(resolverUrl) {
|
|
56604
|
+
this.resolverUrl = resolverUrl;
|
|
56605
|
+
}
|
|
56606
|
+
async getLatestStateById(id) {
|
|
56607
|
+
return this.getStateInfo(id);
|
|
56608
|
+
}
|
|
56609
|
+
async getStateInfoByIdAndState(id, state) {
|
|
56610
|
+
return this.getStateInfo(id, state);
|
|
56611
|
+
}
|
|
56612
|
+
async getGISTProof(id) {
|
|
56613
|
+
const { didDocument } = await resolveDidDocument(Q$2.parseFromId($$1.fromBigInt(id)), this.resolverUrl);
|
|
56614
|
+
const { global } = this.getIden3StateInfo2023(didDocument);
|
|
56615
|
+
if (!global) {
|
|
56616
|
+
throw new Error('GIST root not found');
|
|
56617
|
+
}
|
|
56618
|
+
const { proof } = global;
|
|
56619
|
+
if (!proof) {
|
|
56620
|
+
throw new Error('GIST proof not found');
|
|
56621
|
+
}
|
|
56622
|
+
return {
|
|
56623
|
+
root: global.root,
|
|
56624
|
+
existence: proof.existence,
|
|
56625
|
+
siblings: proof.siblings?.map((sibling) => BigInt(sibling)),
|
|
56626
|
+
index: BigInt(0),
|
|
56627
|
+
value: BigInt(0),
|
|
56628
|
+
auxExistence: !!proof.node_aux,
|
|
56629
|
+
auxIndex: proof.node_aux ? BigInt(proof.node_aux.key) : BigInt(0),
|
|
56630
|
+
auxValue: proof.node_aux ? BigInt(proof.node_aux.value) : BigInt(0)
|
|
56631
|
+
};
|
|
56632
|
+
}
|
|
56633
|
+
async getGISTRootInfo(root, userId) {
|
|
56634
|
+
const { didDocument } = await resolveDidDocument(Q$2.parseFromId($$1.fromBigInt(userId)), this.resolverUrl, {
|
|
56635
|
+
gist: V$1.fromBigInt(root)
|
|
56636
|
+
});
|
|
56637
|
+
const { global } = this.getIden3StateInfo2023(didDocument);
|
|
56638
|
+
if (!global) {
|
|
56639
|
+
throw new Error('GIST root not found');
|
|
56640
|
+
}
|
|
56641
|
+
return global;
|
|
56642
|
+
}
|
|
56643
|
+
getRpcProvider() {
|
|
56644
|
+
return new JsonRpcProvider();
|
|
56645
|
+
}
|
|
56646
|
+
publishState() {
|
|
56647
|
+
throw new Error('publishState method not implemented.');
|
|
56648
|
+
}
|
|
56649
|
+
publishStateGeneric() {
|
|
56650
|
+
throw new Error('publishStateGeneric method not implemented.');
|
|
56651
|
+
}
|
|
56652
|
+
async getStateInfo(id, state) {
|
|
56653
|
+
const opts = state ? { state: V$1.fromBigInt(state) } : undefined;
|
|
56654
|
+
const { didDocument } = await resolveDidDocument(Q$2.parseFromId($$1.fromBigInt(id)), this.resolverUrl, opts);
|
|
56655
|
+
const { info } = this.getIden3StateInfo2023(didDocument);
|
|
56656
|
+
return { ...info };
|
|
56657
|
+
}
|
|
56658
|
+
getIden3StateInfo2023(didDocument) {
|
|
56659
|
+
const vm = didDocument.verificationMethod?.find((i) => i.type === 'Iden3StateInfo2023');
|
|
56660
|
+
if (!vm) {
|
|
56661
|
+
throw new Error('Iden3StateInfo2023 verification method not found');
|
|
56662
|
+
}
|
|
56663
|
+
return vm;
|
|
56664
|
+
}
|
|
56665
|
+
}
|
|
56666
|
+
|
|
56667
|
+
var permitAbi = [
|
|
56668
|
+
{
|
|
56669
|
+
inputs: [
|
|
56670
|
+
],
|
|
56671
|
+
name: "ECDSAInvalidSignature",
|
|
56672
|
+
type: "error"
|
|
56673
|
+
},
|
|
56674
|
+
{
|
|
56675
|
+
inputs: [
|
|
56676
|
+
{
|
|
56677
|
+
internalType: "uint256",
|
|
56678
|
+
name: "length",
|
|
56679
|
+
type: "uint256"
|
|
56680
|
+
}
|
|
56681
|
+
],
|
|
56682
|
+
name: "ECDSAInvalidSignatureLength",
|
|
56683
|
+
type: "error"
|
|
56684
|
+
},
|
|
56685
|
+
{
|
|
56686
|
+
inputs: [
|
|
56687
|
+
{
|
|
56688
|
+
internalType: "bytes32",
|
|
56689
|
+
name: "s",
|
|
56690
|
+
type: "bytes32"
|
|
56691
|
+
}
|
|
56692
|
+
],
|
|
56693
|
+
name: "ECDSAInvalidSignatureS",
|
|
56694
|
+
type: "error"
|
|
56695
|
+
},
|
|
56696
|
+
{
|
|
56697
|
+
inputs: [
|
|
56698
|
+
{
|
|
56699
|
+
internalType: "address",
|
|
56700
|
+
name: "spender",
|
|
56701
|
+
type: "address"
|
|
56702
|
+
},
|
|
56703
|
+
{
|
|
56704
|
+
internalType: "uint256",
|
|
56705
|
+
name: "allowance",
|
|
56706
|
+
type: "uint256"
|
|
56707
|
+
},
|
|
56708
|
+
{
|
|
56709
|
+
internalType: "uint256",
|
|
56710
|
+
name: "needed",
|
|
56711
|
+
type: "uint256"
|
|
56712
|
+
}
|
|
56713
|
+
],
|
|
56714
|
+
name: "ERC20InsufficientAllowance",
|
|
56715
|
+
type: "error"
|
|
56716
|
+
},
|
|
56717
|
+
{
|
|
56718
|
+
inputs: [
|
|
56719
|
+
{
|
|
56720
|
+
internalType: "address",
|
|
56721
|
+
name: "sender",
|
|
56722
|
+
type: "address"
|
|
56723
|
+
},
|
|
56724
|
+
{
|
|
56725
|
+
internalType: "uint256",
|
|
56726
|
+
name: "balance",
|
|
56727
|
+
type: "uint256"
|
|
56728
|
+
},
|
|
56729
|
+
{
|
|
56730
|
+
internalType: "uint256",
|
|
56731
|
+
name: "needed",
|
|
56732
|
+
type: "uint256"
|
|
56733
|
+
}
|
|
56734
|
+
],
|
|
56735
|
+
name: "ERC20InsufficientBalance",
|
|
56736
|
+
type: "error"
|
|
56737
|
+
},
|
|
56738
|
+
{
|
|
56739
|
+
inputs: [
|
|
56740
|
+
{
|
|
56741
|
+
internalType: "address",
|
|
56742
|
+
name: "approver",
|
|
56743
|
+
type: "address"
|
|
56744
|
+
}
|
|
56745
|
+
],
|
|
56746
|
+
name: "ERC20InvalidApprover",
|
|
56747
|
+
type: "error"
|
|
56748
|
+
},
|
|
56749
|
+
{
|
|
56750
|
+
inputs: [
|
|
56751
|
+
{
|
|
56752
|
+
internalType: "address",
|
|
56753
|
+
name: "receiver",
|
|
56754
|
+
type: "address"
|
|
56755
|
+
}
|
|
56756
|
+
],
|
|
56757
|
+
name: "ERC20InvalidReceiver",
|
|
56758
|
+
type: "error"
|
|
56759
|
+
},
|
|
56760
|
+
{
|
|
56761
|
+
inputs: [
|
|
56762
|
+
{
|
|
56763
|
+
internalType: "address",
|
|
56764
|
+
name: "sender",
|
|
56765
|
+
type: "address"
|
|
56766
|
+
}
|
|
56767
|
+
],
|
|
56768
|
+
name: "ERC20InvalidSender",
|
|
56769
|
+
type: "error"
|
|
56770
|
+
},
|
|
56771
|
+
{
|
|
56772
|
+
inputs: [
|
|
56773
|
+
{
|
|
56774
|
+
internalType: "address",
|
|
56775
|
+
name: "spender",
|
|
56776
|
+
type: "address"
|
|
56777
|
+
}
|
|
56778
|
+
],
|
|
56779
|
+
name: "ERC20InvalidSpender",
|
|
56780
|
+
type: "error"
|
|
56781
|
+
},
|
|
56782
|
+
{
|
|
56783
|
+
inputs: [
|
|
56784
|
+
{
|
|
56785
|
+
internalType: "uint256",
|
|
56786
|
+
name: "deadline",
|
|
56787
|
+
type: "uint256"
|
|
56788
|
+
}
|
|
56789
|
+
],
|
|
56790
|
+
name: "ERC2612ExpiredSignature",
|
|
56791
|
+
type: "error"
|
|
56792
|
+
},
|
|
56793
|
+
{
|
|
56794
|
+
inputs: [
|
|
56795
|
+
{
|
|
56796
|
+
internalType: "address",
|
|
56797
|
+
name: "signer",
|
|
56798
|
+
type: "address"
|
|
56799
|
+
},
|
|
56800
|
+
{
|
|
56801
|
+
internalType: "address",
|
|
56802
|
+
name: "owner",
|
|
56803
|
+
type: "address"
|
|
56804
|
+
}
|
|
56805
|
+
],
|
|
56806
|
+
name: "ERC2612InvalidSigner",
|
|
56807
|
+
type: "error"
|
|
56808
|
+
},
|
|
56809
|
+
{
|
|
56810
|
+
inputs: [
|
|
56811
|
+
{
|
|
56812
|
+
internalType: "address",
|
|
56813
|
+
name: "account",
|
|
56814
|
+
type: "address"
|
|
56815
|
+
},
|
|
56816
|
+
{
|
|
56817
|
+
internalType: "uint256",
|
|
56818
|
+
name: "currentNonce",
|
|
56819
|
+
type: "uint256"
|
|
56820
|
+
}
|
|
56821
|
+
],
|
|
56822
|
+
name: "InvalidAccountNonce",
|
|
56823
|
+
type: "error"
|
|
56824
|
+
},
|
|
56825
|
+
{
|
|
56826
|
+
inputs: [
|
|
56827
|
+
],
|
|
56828
|
+
name: "InvalidShortString",
|
|
56829
|
+
type: "error"
|
|
56830
|
+
},
|
|
56831
|
+
{
|
|
56832
|
+
inputs: [
|
|
56833
|
+
{
|
|
56834
|
+
internalType: "string",
|
|
56835
|
+
name: "str",
|
|
56836
|
+
type: "string"
|
|
56837
|
+
}
|
|
56838
|
+
],
|
|
56839
|
+
name: "StringTooLong",
|
|
56840
|
+
type: "error"
|
|
56841
|
+
},
|
|
56842
|
+
{
|
|
56843
|
+
anonymous: false,
|
|
56844
|
+
inputs: [
|
|
56845
|
+
{
|
|
56846
|
+
indexed: true,
|
|
56847
|
+
internalType: "address",
|
|
56848
|
+
name: "owner",
|
|
56849
|
+
type: "address"
|
|
56850
|
+
},
|
|
56851
|
+
{
|
|
56852
|
+
indexed: true,
|
|
56853
|
+
internalType: "address",
|
|
56854
|
+
name: "spender",
|
|
56855
|
+
type: "address"
|
|
56856
|
+
},
|
|
56857
|
+
{
|
|
56858
|
+
indexed: false,
|
|
56859
|
+
internalType: "uint256",
|
|
56860
|
+
name: "value",
|
|
56861
|
+
type: "uint256"
|
|
56862
|
+
}
|
|
56863
|
+
],
|
|
56864
|
+
name: "Approval",
|
|
56865
|
+
type: "event"
|
|
56866
|
+
},
|
|
56867
|
+
{
|
|
56868
|
+
anonymous: false,
|
|
56869
|
+
inputs: [
|
|
56870
|
+
],
|
|
56871
|
+
name: "EIP712DomainChanged",
|
|
56872
|
+
type: "event"
|
|
56873
|
+
},
|
|
56874
|
+
{
|
|
56875
|
+
anonymous: false,
|
|
56876
|
+
inputs: [
|
|
56877
|
+
{
|
|
56878
|
+
indexed: true,
|
|
56879
|
+
internalType: "address",
|
|
56880
|
+
name: "from",
|
|
56881
|
+
type: "address"
|
|
56882
|
+
},
|
|
56883
|
+
{
|
|
56884
|
+
indexed: true,
|
|
56885
|
+
internalType: "address",
|
|
56886
|
+
name: "to",
|
|
56887
|
+
type: "address"
|
|
56888
|
+
},
|
|
56889
|
+
{
|
|
56890
|
+
indexed: false,
|
|
56891
|
+
internalType: "uint256",
|
|
56892
|
+
name: "value",
|
|
56893
|
+
type: "uint256"
|
|
56894
|
+
}
|
|
56895
|
+
],
|
|
56896
|
+
name: "Transfer",
|
|
56897
|
+
type: "event"
|
|
56898
|
+
},
|
|
56899
|
+
{
|
|
56900
|
+
inputs: [
|
|
56901
|
+
],
|
|
56902
|
+
name: "DOMAIN_SEPARATOR",
|
|
56903
|
+
outputs: [
|
|
56904
|
+
{
|
|
56905
|
+
internalType: "bytes32",
|
|
56906
|
+
name: "",
|
|
56907
|
+
type: "bytes32"
|
|
56908
|
+
}
|
|
56909
|
+
],
|
|
56910
|
+
stateMutability: "view",
|
|
56911
|
+
type: "function"
|
|
56912
|
+
},
|
|
56913
|
+
{
|
|
56914
|
+
inputs: [
|
|
56915
|
+
{
|
|
56916
|
+
internalType: "address",
|
|
56917
|
+
name: "owner",
|
|
56918
|
+
type: "address"
|
|
56919
|
+
},
|
|
56920
|
+
{
|
|
56921
|
+
internalType: "address",
|
|
56922
|
+
name: "spender",
|
|
56923
|
+
type: "address"
|
|
56924
|
+
}
|
|
56925
|
+
],
|
|
56926
|
+
name: "allowance",
|
|
56927
|
+
outputs: [
|
|
56928
|
+
{
|
|
56929
|
+
internalType: "uint256",
|
|
56930
|
+
name: "",
|
|
56931
|
+
type: "uint256"
|
|
56932
|
+
}
|
|
56933
|
+
],
|
|
56934
|
+
stateMutability: "view",
|
|
56935
|
+
type: "function"
|
|
56936
|
+
},
|
|
56937
|
+
{
|
|
56938
|
+
inputs: [
|
|
56939
|
+
{
|
|
56940
|
+
internalType: "address",
|
|
56941
|
+
name: "spender",
|
|
56942
|
+
type: "address"
|
|
56943
|
+
},
|
|
56944
|
+
{
|
|
56945
|
+
internalType: "uint256",
|
|
56946
|
+
name: "value",
|
|
56947
|
+
type: "uint256"
|
|
56948
|
+
}
|
|
56949
|
+
],
|
|
56950
|
+
name: "approve",
|
|
56951
|
+
outputs: [
|
|
56952
|
+
{
|
|
56953
|
+
internalType: "bool",
|
|
56954
|
+
name: "",
|
|
56955
|
+
type: "bool"
|
|
56956
|
+
}
|
|
56957
|
+
],
|
|
56958
|
+
stateMutability: "nonpayable",
|
|
56959
|
+
type: "function"
|
|
56960
|
+
},
|
|
56961
|
+
{
|
|
56962
|
+
inputs: [
|
|
56963
|
+
{
|
|
56964
|
+
internalType: "address",
|
|
56965
|
+
name: "account",
|
|
56966
|
+
type: "address"
|
|
56967
|
+
}
|
|
56968
|
+
],
|
|
56969
|
+
name: "balanceOf",
|
|
56970
|
+
outputs: [
|
|
56971
|
+
{
|
|
56972
|
+
internalType: "uint256",
|
|
56973
|
+
name: "",
|
|
56974
|
+
type: "uint256"
|
|
56975
|
+
}
|
|
56976
|
+
],
|
|
56977
|
+
stateMutability: "view",
|
|
56978
|
+
type: "function"
|
|
56979
|
+
},
|
|
56980
|
+
{
|
|
56981
|
+
inputs: [
|
|
56982
|
+
],
|
|
56983
|
+
name: "decimals",
|
|
56984
|
+
outputs: [
|
|
56985
|
+
{
|
|
56986
|
+
internalType: "uint8",
|
|
56987
|
+
name: "",
|
|
56988
|
+
type: "uint8"
|
|
56989
|
+
}
|
|
56990
|
+
],
|
|
56991
|
+
stateMutability: "view",
|
|
56992
|
+
type: "function"
|
|
56993
|
+
},
|
|
56994
|
+
{
|
|
56995
|
+
inputs: [
|
|
56996
|
+
],
|
|
56997
|
+
name: "eip712Domain",
|
|
56998
|
+
outputs: [
|
|
56999
|
+
{
|
|
57000
|
+
internalType: "bytes1",
|
|
57001
|
+
name: "fields",
|
|
57002
|
+
type: "bytes1"
|
|
57003
|
+
},
|
|
57004
|
+
{
|
|
57005
|
+
internalType: "string",
|
|
57006
|
+
name: "name",
|
|
57007
|
+
type: "string"
|
|
57008
|
+
},
|
|
57009
|
+
{
|
|
57010
|
+
internalType: "string",
|
|
57011
|
+
name: "version",
|
|
57012
|
+
type: "string"
|
|
57013
|
+
},
|
|
57014
|
+
{
|
|
57015
|
+
internalType: "uint256",
|
|
57016
|
+
name: "chainId",
|
|
57017
|
+
type: "uint256"
|
|
57018
|
+
},
|
|
57019
|
+
{
|
|
57020
|
+
internalType: "address",
|
|
57021
|
+
name: "verifyingContract",
|
|
57022
|
+
type: "address"
|
|
57023
|
+
},
|
|
57024
|
+
{
|
|
57025
|
+
internalType: "bytes32",
|
|
57026
|
+
name: "salt",
|
|
57027
|
+
type: "bytes32"
|
|
57028
|
+
},
|
|
57029
|
+
{
|
|
57030
|
+
internalType: "uint256[]",
|
|
57031
|
+
name: "extensions",
|
|
57032
|
+
type: "uint256[]"
|
|
57033
|
+
}
|
|
57034
|
+
],
|
|
57035
|
+
stateMutability: "view",
|
|
57036
|
+
type: "function"
|
|
57037
|
+
},
|
|
57038
|
+
{
|
|
57039
|
+
inputs: [
|
|
57040
|
+
],
|
|
57041
|
+
name: "name",
|
|
57042
|
+
outputs: [
|
|
57043
|
+
{
|
|
57044
|
+
internalType: "string",
|
|
57045
|
+
name: "",
|
|
57046
|
+
type: "string"
|
|
57047
|
+
}
|
|
57048
|
+
],
|
|
57049
|
+
stateMutability: "view",
|
|
57050
|
+
type: "function"
|
|
57051
|
+
},
|
|
57052
|
+
{
|
|
57053
|
+
inputs: [
|
|
57054
|
+
{
|
|
57055
|
+
internalType: "address",
|
|
57056
|
+
name: "owner",
|
|
57057
|
+
type: "address"
|
|
57058
|
+
}
|
|
57059
|
+
],
|
|
57060
|
+
name: "nonces",
|
|
57061
|
+
outputs: [
|
|
57062
|
+
{
|
|
57063
|
+
internalType: "uint256",
|
|
57064
|
+
name: "",
|
|
57065
|
+
type: "uint256"
|
|
57066
|
+
}
|
|
57067
|
+
],
|
|
57068
|
+
stateMutability: "view",
|
|
57069
|
+
type: "function"
|
|
57070
|
+
},
|
|
57071
|
+
{
|
|
57072
|
+
inputs: [
|
|
57073
|
+
{
|
|
57074
|
+
internalType: "address",
|
|
57075
|
+
name: "owner",
|
|
57076
|
+
type: "address"
|
|
57077
|
+
},
|
|
57078
|
+
{
|
|
57079
|
+
internalType: "address",
|
|
57080
|
+
name: "spender",
|
|
57081
|
+
type: "address"
|
|
57082
|
+
},
|
|
57083
|
+
{
|
|
57084
|
+
internalType: "uint256",
|
|
57085
|
+
name: "value",
|
|
57086
|
+
type: "uint256"
|
|
57087
|
+
},
|
|
57088
|
+
{
|
|
57089
|
+
internalType: "uint256",
|
|
57090
|
+
name: "deadline",
|
|
57091
|
+
type: "uint256"
|
|
57092
|
+
},
|
|
57093
|
+
{
|
|
57094
|
+
internalType: "uint8",
|
|
57095
|
+
name: "v",
|
|
57096
|
+
type: "uint8"
|
|
57097
|
+
},
|
|
57098
|
+
{
|
|
57099
|
+
internalType: "bytes32",
|
|
57100
|
+
name: "r",
|
|
57101
|
+
type: "bytes32"
|
|
57102
|
+
},
|
|
57103
|
+
{
|
|
57104
|
+
internalType: "bytes32",
|
|
57105
|
+
name: "s",
|
|
57106
|
+
type: "bytes32"
|
|
57107
|
+
}
|
|
57108
|
+
],
|
|
57109
|
+
name: "permit",
|
|
57110
|
+
outputs: [
|
|
57111
|
+
],
|
|
57112
|
+
stateMutability: "nonpayable",
|
|
57113
|
+
type: "function"
|
|
57114
|
+
},
|
|
57115
|
+
{
|
|
57116
|
+
inputs: [
|
|
57117
|
+
],
|
|
57118
|
+
name: "symbol",
|
|
57119
|
+
outputs: [
|
|
57120
|
+
{
|
|
57121
|
+
internalType: "string",
|
|
57122
|
+
name: "",
|
|
57123
|
+
type: "string"
|
|
57124
|
+
}
|
|
57125
|
+
],
|
|
57126
|
+
stateMutability: "view",
|
|
57127
|
+
type: "function"
|
|
57128
|
+
},
|
|
57129
|
+
{
|
|
57130
|
+
inputs: [
|
|
57131
|
+
],
|
|
57132
|
+
name: "totalSupply",
|
|
57133
|
+
outputs: [
|
|
57134
|
+
{
|
|
57135
|
+
internalType: "uint256",
|
|
57136
|
+
name: "",
|
|
57137
|
+
type: "uint256"
|
|
57138
|
+
}
|
|
57139
|
+
],
|
|
57140
|
+
stateMutability: "view",
|
|
57141
|
+
type: "function"
|
|
57142
|
+
},
|
|
57143
|
+
{
|
|
57144
|
+
inputs: [
|
|
57145
|
+
{
|
|
57146
|
+
internalType: "address",
|
|
57147
|
+
name: "to",
|
|
57148
|
+
type: "address"
|
|
57149
|
+
},
|
|
57150
|
+
{
|
|
57151
|
+
internalType: "uint256",
|
|
57152
|
+
name: "value",
|
|
57153
|
+
type: "uint256"
|
|
57154
|
+
}
|
|
57155
|
+
],
|
|
57156
|
+
name: "transfer",
|
|
57157
|
+
outputs: [
|
|
57158
|
+
{
|
|
57159
|
+
internalType: "bool",
|
|
57160
|
+
name: "",
|
|
57161
|
+
type: "bool"
|
|
57162
|
+
}
|
|
57163
|
+
],
|
|
57164
|
+
stateMutability: "nonpayable",
|
|
57165
|
+
type: "function"
|
|
57166
|
+
},
|
|
57167
|
+
{
|
|
57168
|
+
inputs: [
|
|
57169
|
+
{
|
|
57170
|
+
internalType: "address",
|
|
57171
|
+
name: "from",
|
|
57172
|
+
type: "address"
|
|
57173
|
+
},
|
|
57174
|
+
{
|
|
57175
|
+
internalType: "address",
|
|
57176
|
+
name: "to",
|
|
57177
|
+
type: "address"
|
|
57178
|
+
},
|
|
57179
|
+
{
|
|
57180
|
+
internalType: "uint256",
|
|
57181
|
+
name: "value",
|
|
57182
|
+
type: "uint256"
|
|
57183
|
+
}
|
|
57184
|
+
],
|
|
57185
|
+
name: "transferFrom",
|
|
57186
|
+
outputs: [
|
|
57187
|
+
{
|
|
57188
|
+
internalType: "bool",
|
|
57189
|
+
name: "",
|
|
57190
|
+
type: "bool"
|
|
57191
|
+
}
|
|
57192
|
+
],
|
|
57193
|
+
stateMutability: "nonpayable",
|
|
57194
|
+
type: "function"
|
|
57195
|
+
}
|
|
57196
|
+
];
|
|
57197
|
+
|
|
57198
|
+
var erc20Abi = [
|
|
57199
|
+
{
|
|
57200
|
+
inputs: [
|
|
57201
|
+
{
|
|
57202
|
+
internalType: "uint256",
|
|
57203
|
+
name: "initialSupply",
|
|
57204
|
+
type: "uint256"
|
|
57205
|
+
}
|
|
57206
|
+
],
|
|
57207
|
+
stateMutability: "nonpayable",
|
|
57208
|
+
type: "constructor"
|
|
54294
57209
|
},
|
|
54295
57210
|
{
|
|
54296
57211
|
inputs: [
|
|
@@ -54378,66 +57293,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54378
57293
|
name: "ERC20InvalidSpender",
|
|
54379
57294
|
type: "error"
|
|
54380
57295
|
},
|
|
54381
|
-
{
|
|
54382
|
-
inputs: [
|
|
54383
|
-
{
|
|
54384
|
-
internalType: "uint256",
|
|
54385
|
-
name: "deadline",
|
|
54386
|
-
type: "uint256"
|
|
54387
|
-
}
|
|
54388
|
-
],
|
|
54389
|
-
name: "ERC2612ExpiredSignature",
|
|
54390
|
-
type: "error"
|
|
54391
|
-
},
|
|
54392
|
-
{
|
|
54393
|
-
inputs: [
|
|
54394
|
-
{
|
|
54395
|
-
internalType: "address",
|
|
54396
|
-
name: "signer",
|
|
54397
|
-
type: "address"
|
|
54398
|
-
},
|
|
54399
|
-
{
|
|
54400
|
-
internalType: "address",
|
|
54401
|
-
name: "owner",
|
|
54402
|
-
type: "address"
|
|
54403
|
-
}
|
|
54404
|
-
],
|
|
54405
|
-
name: "ERC2612InvalidSigner",
|
|
54406
|
-
type: "error"
|
|
54407
|
-
},
|
|
54408
|
-
{
|
|
54409
|
-
inputs: [
|
|
54410
|
-
{
|
|
54411
|
-
internalType: "address",
|
|
54412
|
-
name: "account",
|
|
54413
|
-
type: "address"
|
|
54414
|
-
},
|
|
54415
|
-
{
|
|
54416
|
-
internalType: "uint256",
|
|
54417
|
-
name: "currentNonce",
|
|
54418
|
-
type: "uint256"
|
|
54419
|
-
}
|
|
54420
|
-
],
|
|
54421
|
-
name: "InvalidAccountNonce",
|
|
54422
|
-
type: "error"
|
|
54423
|
-
},
|
|
54424
|
-
{
|
|
54425
|
-
inputs: [
|
|
54426
|
-
],
|
|
54427
|
-
name: "InvalidShortString",
|
|
54428
|
-
type: "error"
|
|
54429
|
-
},
|
|
54430
|
-
{
|
|
54431
|
-
inputs: [
|
|
54432
|
-
{
|
|
54433
|
-
internalType: "string",
|
|
54434
|
-
name: "str",
|
|
54435
|
-
type: "string"
|
|
54436
|
-
}
|
|
54437
|
-
],
|
|
54438
|
-
name: "StringTooLong",
|
|
54439
|
-
type: "error"
|
|
54440
|
-
},
|
|
54441
57296
|
{
|
|
54442
57297
|
anonymous: false,
|
|
54443
57298
|
inputs: [
|
|
@@ -54463,13 +57318,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54463
57318
|
name: "Approval",
|
|
54464
57319
|
type: "event"
|
|
54465
57320
|
},
|
|
54466
|
-
{
|
|
54467
|
-
anonymous: false,
|
|
54468
|
-
inputs: [
|
|
54469
|
-
],
|
|
54470
|
-
name: "EIP712DomainChanged",
|
|
54471
|
-
type: "event"
|
|
54472
|
-
},
|
|
54473
57321
|
{
|
|
54474
57322
|
anonymous: false,
|
|
54475
57323
|
inputs: [
|
|
@@ -54495,20 +57343,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54495
57343
|
name: "Transfer",
|
|
54496
57344
|
type: "event"
|
|
54497
57345
|
},
|
|
54498
|
-
{
|
|
54499
|
-
inputs: [
|
|
54500
|
-
],
|
|
54501
|
-
name: "DOMAIN_SEPARATOR",
|
|
54502
|
-
outputs: [
|
|
54503
|
-
{
|
|
54504
|
-
internalType: "bytes32",
|
|
54505
|
-
name: "",
|
|
54506
|
-
type: "bytes32"
|
|
54507
|
-
}
|
|
54508
|
-
],
|
|
54509
|
-
stateMutability: "view",
|
|
54510
|
-
type: "function"
|
|
54511
|
-
},
|
|
54512
57346
|
{
|
|
54513
57347
|
inputs: [
|
|
54514
57348
|
{
|
|
@@ -54590,50 +57424,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54590
57424
|
stateMutability: "view",
|
|
54591
57425
|
type: "function"
|
|
54592
57426
|
},
|
|
54593
|
-
{
|
|
54594
|
-
inputs: [
|
|
54595
|
-
],
|
|
54596
|
-
name: "eip712Domain",
|
|
54597
|
-
outputs: [
|
|
54598
|
-
{
|
|
54599
|
-
internalType: "bytes1",
|
|
54600
|
-
name: "fields",
|
|
54601
|
-
type: "bytes1"
|
|
54602
|
-
},
|
|
54603
|
-
{
|
|
54604
|
-
internalType: "string",
|
|
54605
|
-
name: "name",
|
|
54606
|
-
type: "string"
|
|
54607
|
-
},
|
|
54608
|
-
{
|
|
54609
|
-
internalType: "string",
|
|
54610
|
-
name: "version",
|
|
54611
|
-
type: "string"
|
|
54612
|
-
},
|
|
54613
|
-
{
|
|
54614
|
-
internalType: "uint256",
|
|
54615
|
-
name: "chainId",
|
|
54616
|
-
type: "uint256"
|
|
54617
|
-
},
|
|
54618
|
-
{
|
|
54619
|
-
internalType: "address",
|
|
54620
|
-
name: "verifyingContract",
|
|
54621
|
-
type: "address"
|
|
54622
|
-
},
|
|
54623
|
-
{
|
|
54624
|
-
internalType: "bytes32",
|
|
54625
|
-
name: "salt",
|
|
54626
|
-
type: "bytes32"
|
|
54627
|
-
},
|
|
54628
|
-
{
|
|
54629
|
-
internalType: "uint256[]",
|
|
54630
|
-
name: "extensions",
|
|
54631
|
-
type: "uint256[]"
|
|
54632
|
-
}
|
|
54633
|
-
],
|
|
54634
|
-
stateMutability: "view",
|
|
54635
|
-
type: "function"
|
|
54636
|
-
},
|
|
54637
57427
|
{
|
|
54638
57428
|
inputs: [
|
|
54639
57429
|
],
|
|
@@ -54648,69 +57438,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54648
57438
|
stateMutability: "view",
|
|
54649
57439
|
type: "function"
|
|
54650
57440
|
},
|
|
54651
|
-
{
|
|
54652
|
-
inputs: [
|
|
54653
|
-
{
|
|
54654
|
-
internalType: "address",
|
|
54655
|
-
name: "owner",
|
|
54656
|
-
type: "address"
|
|
54657
|
-
}
|
|
54658
|
-
],
|
|
54659
|
-
name: "nonces",
|
|
54660
|
-
outputs: [
|
|
54661
|
-
{
|
|
54662
|
-
internalType: "uint256",
|
|
54663
|
-
name: "",
|
|
54664
|
-
type: "uint256"
|
|
54665
|
-
}
|
|
54666
|
-
],
|
|
54667
|
-
stateMutability: "view",
|
|
54668
|
-
type: "function"
|
|
54669
|
-
},
|
|
54670
|
-
{
|
|
54671
|
-
inputs: [
|
|
54672
|
-
{
|
|
54673
|
-
internalType: "address",
|
|
54674
|
-
name: "owner",
|
|
54675
|
-
type: "address"
|
|
54676
|
-
},
|
|
54677
|
-
{
|
|
54678
|
-
internalType: "address",
|
|
54679
|
-
name: "spender",
|
|
54680
|
-
type: "address"
|
|
54681
|
-
},
|
|
54682
|
-
{
|
|
54683
|
-
internalType: "uint256",
|
|
54684
|
-
name: "value",
|
|
54685
|
-
type: "uint256"
|
|
54686
|
-
},
|
|
54687
|
-
{
|
|
54688
|
-
internalType: "uint256",
|
|
54689
|
-
name: "deadline",
|
|
54690
|
-
type: "uint256"
|
|
54691
|
-
},
|
|
54692
|
-
{
|
|
54693
|
-
internalType: "uint8",
|
|
54694
|
-
name: "v",
|
|
54695
|
-
type: "uint8"
|
|
54696
|
-
},
|
|
54697
|
-
{
|
|
54698
|
-
internalType: "bytes32",
|
|
54699
|
-
name: "r",
|
|
54700
|
-
type: "bytes32"
|
|
54701
|
-
},
|
|
54702
|
-
{
|
|
54703
|
-
internalType: "bytes32",
|
|
54704
|
-
name: "s",
|
|
54705
|
-
type: "bytes32"
|
|
54706
|
-
}
|
|
54707
|
-
],
|
|
54708
|
-
name: "permit",
|
|
54709
|
-
outputs: [
|
|
54710
|
-
],
|
|
54711
|
-
stateMutability: "nonpayable",
|
|
54712
|
-
type: "function"
|
|
54713
|
-
},
|
|
54714
57441
|
{
|
|
54715
57442
|
inputs: [
|
|
54716
57443
|
],
|
|
@@ -54805,10 +57532,11 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54805
57532
|
* @returns {Promise<PaymentRequestMessage>}
|
|
54806
57533
|
*/
|
|
54807
57534
|
async function getPermitSignature(signer, tokenAddress, spender, value, deadline) {
|
|
54808
|
-
const erc20PermitContract = new Contract(tokenAddress,
|
|
57535
|
+
const erc20PermitContract = new Contract(tokenAddress, permitAbi, signer);
|
|
54809
57536
|
const nonce = await erc20PermitContract.nonces(await signer.getAddress());
|
|
54810
57537
|
const domainData = await erc20PermitContract.eip712Domain();
|
|
54811
57538
|
const domain = {
|
|
57539
|
+
name: domainData[1],
|
|
54812
57540
|
version: domainData[2],
|
|
54813
57541
|
chainId: domainData[3],
|
|
54814
57542
|
verifyingContract: tokenAddress
|
|
@@ -54831,6 +57559,16 @@ var PolygonIdSdk = (function (exports) {
|
|
|
54831
57559
|
};
|
|
54832
57560
|
return signer.signTypedData(domain, types, message);
|
|
54833
57561
|
}
|
|
57562
|
+
/**
|
|
57563
|
+
* @beta
|
|
57564
|
+
* getERC20Decimals is a function to retrieve the number of decimals of an ERC20 token
|
|
57565
|
+
* @param {string} tokenAddress - Token address
|
|
57566
|
+
* @param {ethers.ContractRunner} runner - Contract runner
|
|
57567
|
+
*/
|
|
57568
|
+
async function getERC20Decimals(tokenAddress, runner) {
|
|
57569
|
+
const erc20Contract = new Contract(tokenAddress, erc20Abi, runner);
|
|
57570
|
+
return erc20Contract.decimals();
|
|
57571
|
+
}
|
|
54834
57572
|
|
|
54835
57573
|
/**
|
|
54836
57574
|
* Type of MerkleTree
|
|
@@ -56509,6 +59247,24 @@ var PolygonIdSdk = (function (exports) {
|
|
|
56509
59247
|
}
|
|
56510
59248
|
}
|
|
56511
59249
|
|
|
59250
|
+
class DidDocumentCredentialStatusResolver {
|
|
59251
|
+
constructor(didResolverUrl) {
|
|
59252
|
+
this.didResolverUrl = didResolverUrl;
|
|
59253
|
+
}
|
|
59254
|
+
async resolve(credentialStatus, opts) {
|
|
59255
|
+
if (!opts?.issuerDID) {
|
|
59256
|
+
throw new Error('IssuerDID is not set in options');
|
|
59257
|
+
}
|
|
59258
|
+
const url = `${this.didResolverUrl}/1.0/credential-status/${encodeURIComponent(opts.issuerDID.string())}`;
|
|
59259
|
+
const resp = await fetch(url, {
|
|
59260
|
+
method: 'POST',
|
|
59261
|
+
body: JSON.stringify(credentialStatus)
|
|
59262
|
+
});
|
|
59263
|
+
const data = await resp.json();
|
|
59264
|
+
return data;
|
|
59265
|
+
}
|
|
59266
|
+
}
|
|
59267
|
+
|
|
56512
59268
|
/**
|
|
56513
59269
|
*
|
|
56514
59270
|
* Wallet instance is a wrapper of CRUD logic for W3C credentials,
|
|
@@ -56535,40 +59291,18 @@ var PolygonIdSdk = (function (exports) {
|
|
|
56535
59291
|
if (!schema.$metadata.uris['jsonLdContext']) {
|
|
56536
59292
|
throw new Error('jsonLdContext is missing is the schema');
|
|
56537
59293
|
}
|
|
56538
|
-
|
|
56539
|
-
|
|
56540
|
-
|
|
56541
|
-
|
|
56542
|
-
|
|
56543
|
-
|
|
56544
|
-
|
|
56545
|
-
|
|
56546
|
-
|
|
56547
|
-
|
|
56548
|
-
|
|
56549
|
-
|
|
56550
|
-
VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,
|
|
56551
|
-
request.type
|
|
56552
|
-
];
|
|
56553
|
-
const expirationDate = !request.expiration || request.expiration == 0 ? null : request.expiration;
|
|
56554
|
-
const credentialSubject = request.credentialSubject;
|
|
56555
|
-
credentialSubject['type'] = request.type;
|
|
56556
|
-
const cr = new W3CCredential();
|
|
56557
|
-
cr.id = `urn:${v4()}`;
|
|
56558
|
-
cr['@context'] = context;
|
|
56559
|
-
cr.type = credentialType;
|
|
56560
|
-
cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined;
|
|
56561
|
-
cr.refreshService = request.refreshService;
|
|
56562
|
-
cr.displayMethod = request.displayMethod;
|
|
56563
|
-
cr.issuanceDate = new Date().toISOString();
|
|
56564
|
-
cr.credentialSubject = credentialSubject;
|
|
56565
|
-
cr.issuer = issuer.string();
|
|
56566
|
-
cr.credentialSchema = {
|
|
56567
|
-
id: request.credentialSchema,
|
|
56568
|
-
type: VerifiableConstants.JSON_SCHEMA_VALIDATOR
|
|
56569
|
-
};
|
|
56570
|
-
cr.credentialStatus = this.buildCredentialStatus(request, issuer);
|
|
56571
|
-
return cr;
|
|
59294
|
+
// do copy of request to avoid mutation
|
|
59295
|
+
const r = { ...request };
|
|
59296
|
+
r.context = r.context ?? [];
|
|
59297
|
+
if (r.displayMethod?.type === exports.DisplayMethodType.Iden3BasicDisplayMethodV1 &&
|
|
59298
|
+
!r.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD)) {
|
|
59299
|
+
r.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD);
|
|
59300
|
+
}
|
|
59301
|
+
r.context.push(schema.$metadata.uris['jsonLdContext']);
|
|
59302
|
+
r.expiration = r.expiration ? r.expiration * 1000 : undefined;
|
|
59303
|
+
r.id = r.id ? r.id : `urn:${v4()}`;
|
|
59304
|
+
r.issuanceDate = r.issuanceDate ? r.issuanceDate * 1000 : Date.now();
|
|
59305
|
+
return W3CCredential.fromCredentialRequest(issuer, r);
|
|
56572
59306
|
};
|
|
56573
59307
|
// if no credential status resolvers are provided
|
|
56574
59308
|
// register default issuer resolver
|
|
@@ -56638,51 +59372,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
56638
59372
|
}
|
|
56639
59373
|
return statusResolver.resolve(credStatus, credentialStatusResolveOptions);
|
|
56640
59374
|
}
|
|
56641
|
-
/**
|
|
56642
|
-
* Builds credential status
|
|
56643
|
-
* @param {CredentialRequest} request
|
|
56644
|
-
* @returns `CredentialStatus`
|
|
56645
|
-
*/
|
|
56646
|
-
buildCredentialStatus(request, issuer) {
|
|
56647
|
-
const credentialStatus = {
|
|
56648
|
-
id: request.revocationOpts.id,
|
|
56649
|
-
type: request.revocationOpts.type,
|
|
56650
|
-
revocationNonce: request.revocationOpts.nonce
|
|
56651
|
-
};
|
|
56652
|
-
switch (request.revocationOpts.type) {
|
|
56653
|
-
case exports.CredentialStatusType.SparseMerkleTreeProof:
|
|
56654
|
-
return {
|
|
56655
|
-
...credentialStatus,
|
|
56656
|
-
id: `${credentialStatus.id.replace(/\/$/, '')}/${credentialStatus.revocationNonce}`
|
|
56657
|
-
};
|
|
56658
|
-
case exports.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
|
|
56659
|
-
return {
|
|
56660
|
-
...credentialStatus,
|
|
56661
|
-
id: request.revocationOpts.issuerState
|
|
56662
|
-
? `${credentialStatus.id.replace(/\/$/, '')}/node?state=${request.revocationOpts.issuerState}`
|
|
56663
|
-
: `${credentialStatus.id.replace(/\/$/, '')}`
|
|
56664
|
-
};
|
|
56665
|
-
case exports.CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023: {
|
|
56666
|
-
const issuerId = Q$2.idFromDID(issuer);
|
|
56667
|
-
const chainId = et$2(Q$2.blockchainFromId(issuerId), Q$2.networkIdFromId(issuerId));
|
|
56668
|
-
const searchParams = [
|
|
56669
|
-
['revocationNonce', request.revocationOpts.nonce?.toString() || ''],
|
|
56670
|
-
['contractAddress', `${chainId}:${request.revocationOpts.id}`],
|
|
56671
|
-
['state', request.revocationOpts.issuerState || '']
|
|
56672
|
-
]
|
|
56673
|
-
.filter(([, value]) => Boolean(value))
|
|
56674
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
56675
|
-
.join('&');
|
|
56676
|
-
return {
|
|
56677
|
-
...credentialStatus,
|
|
56678
|
-
// `[did]:[methodid]:[chain]:[network]:[id]/credentialStatus?(revocationNonce=value)&[contractAddress=[chainID]:[contractAddress]]&(state=issuerState)`
|
|
56679
|
-
id: `${issuer.string()}/credentialStatus?${searchParams}`
|
|
56680
|
-
};
|
|
56681
|
-
}
|
|
56682
|
-
default:
|
|
56683
|
-
return credentialStatus;
|
|
56684
|
-
}
|
|
56685
|
-
}
|
|
56686
59375
|
/**
|
|
56687
59376
|
* {@inheritDoc ICredentialWallet.findById}
|
|
56688
59377
|
*/
|
|
@@ -79402,10 +82091,34 @@ var PolygonIdSdk = (function (exports) {
|
|
|
79402
82091
|
return this.handleFetchRequest(message);
|
|
79403
82092
|
case PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE:
|
|
79404
82093
|
return this.handleIssuanceResponseMsg(message);
|
|
82094
|
+
case PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: {
|
|
82095
|
+
const result = await this.handleOnchainOfferMessage(message);
|
|
82096
|
+
if (Array.isArray(result)) {
|
|
82097
|
+
const credWallet = this.opts?.credentialWallet;
|
|
82098
|
+
if (!credWallet)
|
|
82099
|
+
throw new Error('Credential wallet is not provided');
|
|
82100
|
+
await credWallet.saveAll(result);
|
|
82101
|
+
return null;
|
|
82102
|
+
}
|
|
82103
|
+
return result;
|
|
82104
|
+
}
|
|
79405
82105
|
default:
|
|
79406
82106
|
return super.handle(message, ctx);
|
|
79407
82107
|
}
|
|
79408
82108
|
}
|
|
82109
|
+
async handleOnchainOfferMessage(offerMessage) {
|
|
82110
|
+
if (!this.opts?.onchainIssuer) {
|
|
82111
|
+
throw new Error('onchain issuer is not provided');
|
|
82112
|
+
}
|
|
82113
|
+
const credentials = [];
|
|
82114
|
+
for (const credentialInfo of offerMessage.body.credentials) {
|
|
82115
|
+
const issuerDID = Q$2.parse(offerMessage.from);
|
|
82116
|
+
const userDID = Q$2.parse(offerMessage.to);
|
|
82117
|
+
const credential = await this.opts.onchainIssuer.getCredential(issuerDID, userDID, BigInt(credentialInfo.id));
|
|
82118
|
+
credentials.push(credential);
|
|
82119
|
+
}
|
|
82120
|
+
return credentials;
|
|
82121
|
+
}
|
|
79409
82122
|
async handleOfferMessage(offerMessage, ctx) {
|
|
79410
82123
|
if (!ctx.mediaType) {
|
|
79411
82124
|
ctx.mediaType = MediaType.ZKPMessage;
|
|
@@ -79490,6 +82203,14 @@ var PolygonIdSdk = (function (exports) {
|
|
|
79490
82203
|
}
|
|
79491
82204
|
throw new Error('invalid protocol message response');
|
|
79492
82205
|
}
|
|
82206
|
+
/**
|
|
82207
|
+
* Handles only messages with credentials/1.0/onchain-offer type
|
|
82208
|
+
* @beta
|
|
82209
|
+
*/
|
|
82210
|
+
async handleOnchainOffer(offer) {
|
|
82211
|
+
const offerMessage = await FetchHandler.unpackMessage(this._packerMgr, offer, PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE);
|
|
82212
|
+
return this.handleOnchainOfferMessage(offerMessage);
|
|
82213
|
+
}
|
|
79493
82214
|
async handleFetchRequest(msgRequest) {
|
|
79494
82215
|
if (!msgRequest.to) {
|
|
79495
82216
|
throw new Error("failed request. empty 'to' field");
|
|
@@ -80143,19 +82864,20 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80143
82864
|
return request;
|
|
80144
82865
|
}
|
|
80145
82866
|
async function verifyEIP712TypedData(data, resolver) {
|
|
82867
|
+
const convertedAmount = await convertPaymentAmount(data.amount, data.currency);
|
|
80146
82868
|
const paymentData = data.type === exports.PaymentRequestDataType.Iden3PaymentRailsRequestV1
|
|
80147
82869
|
? {
|
|
80148
82870
|
recipient: data.recipient,
|
|
80149
|
-
amount:
|
|
80150
|
-
expirationDate: new Date(data.expirationDate)
|
|
82871
|
+
amount: convertedAmount,
|
|
82872
|
+
expirationDate: b$4(new Date(data.expirationDate)),
|
|
80151
82873
|
nonce: data.nonce,
|
|
80152
82874
|
metadata: '0x'
|
|
80153
82875
|
}
|
|
80154
82876
|
: {
|
|
80155
82877
|
tokenAddress: data.tokenAddress,
|
|
80156
82878
|
recipient: data.recipient,
|
|
80157
|
-
amount:
|
|
80158
|
-
expirationDate: new Date(data.expirationDate)
|
|
82879
|
+
amount: convertedAmount,
|
|
82880
|
+
expirationDate: b$4(new Date(data.expirationDate)),
|
|
80159
82881
|
nonce: data.nonce,
|
|
80160
82882
|
metadata: '0x'
|
|
80161
82883
|
};
|
|
@@ -80178,6 +82900,30 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80178
82900
|
}
|
|
80179
82901
|
throw new Error(`failed request. no matching verificationMethod`);
|
|
80180
82902
|
}
|
|
82903
|
+
async function convertPaymentAmount(amount, currency) {
|
|
82904
|
+
let convertedAmount = 0n;
|
|
82905
|
+
switch (currency) {
|
|
82906
|
+
case exports.SupportedCurrencies.ETH:
|
|
82907
|
+
case exports.SupportedCurrencies.POL:
|
|
82908
|
+
case exports.SupportedCurrencies.MATIC:
|
|
82909
|
+
convertedAmount = parseEther(amount.toString());
|
|
82910
|
+
break;
|
|
82911
|
+
case exports.SupportedCurrencies.ETH_WEI:
|
|
82912
|
+
convertedAmount = parseUnits$1(amount.toString(), 'wei');
|
|
82913
|
+
break;
|
|
82914
|
+
case exports.SupportedCurrencies.ETH_GWEI:
|
|
82915
|
+
convertedAmount = parseUnits$1(amount.toString(), 'gwei');
|
|
82916
|
+
break;
|
|
82917
|
+
case exports.SupportedCurrencies.USDC:
|
|
82918
|
+
case exports.SupportedCurrencies.USDT: {
|
|
82919
|
+
convertedAmount = parseUnits$1(amount.toString(), 6);
|
|
82920
|
+
break;
|
|
82921
|
+
}
|
|
82922
|
+
default:
|
|
82923
|
+
throw new Error(`failed request. unsupported currency ${currency}`);
|
|
82924
|
+
}
|
|
82925
|
+
return convertedAmount;
|
|
82926
|
+
}
|
|
80181
82927
|
/**
|
|
80182
82928
|
* @beta
|
|
80183
82929
|
* createPayment is a function to create protocol payment message
|
|
@@ -80375,26 +83121,25 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80375
83121
|
if (type === exports.PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1 && !tokenAddress) {
|
|
80376
83122
|
throw new Error(`failed request. no token address for currency ${currency}`);
|
|
80377
83123
|
}
|
|
80378
|
-
const
|
|
80379
|
-
? new Date(expirationDate).getTime()
|
|
80380
|
-
: new Date(new Date().setHours(new Date().getHours() + 1)).getTime();
|
|
83124
|
+
const expirationDateRequired = expirationDate ?? new Date(new Date().setHours(new Date().getHours() + 1));
|
|
80381
83125
|
const typeUrl = `https://schema.iden3.io/core/json/${type}.json`;
|
|
80382
83126
|
const typesFetchResult = await fetch(typeUrl);
|
|
80383
83127
|
const types = await typesFetchResult.json();
|
|
80384
83128
|
delete types.EIP712Domain;
|
|
83129
|
+
const convertedAmount = await convertPaymentAmount(amount, currency);
|
|
80385
83130
|
const paymentData = type === exports.PaymentRequestDataType.Iden3PaymentRailsRequestV1
|
|
80386
83131
|
? {
|
|
80387
83132
|
recipient,
|
|
80388
|
-
amount,
|
|
80389
|
-
expirationDate:
|
|
83133
|
+
amount: convertedAmount,
|
|
83134
|
+
expirationDate: b$4(expirationDateRequired),
|
|
80390
83135
|
nonce,
|
|
80391
83136
|
metadata: '0x'
|
|
80392
83137
|
}
|
|
80393
83138
|
: {
|
|
80394
83139
|
tokenAddress,
|
|
80395
83140
|
recipient,
|
|
80396
|
-
amount,
|
|
80397
|
-
expirationDate:
|
|
83141
|
+
amount: convertedAmount,
|
|
83142
|
+
expirationDate: b$4(expirationDateRequired),
|
|
80398
83143
|
nonce,
|
|
80399
83144
|
metadata: '0x'
|
|
80400
83145
|
};
|
|
@@ -80428,7 +83173,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80428
83173
|
recipient,
|
|
80429
83174
|
amount: amount.toString(),
|
|
80430
83175
|
currency,
|
|
80431
|
-
expirationDate:
|
|
83176
|
+
expirationDate: expirationDateRequired.toISOString(),
|
|
80432
83177
|
nonce: nonce.toString(),
|
|
80433
83178
|
metadata: '0x',
|
|
80434
83179
|
proof
|
|
@@ -82587,6 +85332,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
82587
85332
|
exports.CredentialWallet = CredentialWallet;
|
|
82588
85333
|
exports.DIDDocumentJSONSchema = DIDDocumentJSONSchema;
|
|
82589
85334
|
exports.DataPrepareHandlerFunc = DataPrepareHandlerFunc;
|
|
85335
|
+
exports.DidDocumentCredentialStatusResolver = DidDocumentCredentialStatusResolver;
|
|
85336
|
+
exports.DidResolverStateReadonlyStorage = DidResolverStateReadonlyStorage;
|
|
82590
85337
|
exports.Ed25519Provider = Ed25519Provider;
|
|
82591
85338
|
exports.ErrorEmptyAuthClaimNonRevProof = ErrorEmptyAuthClaimNonRevProof;
|
|
82592
85339
|
exports.ErrorEmptyAuthClaimProof = ErrorEmptyAuthClaimProof;
|
|
@@ -82629,6 +85376,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
82629
85376
|
exports.OnChainResolver = OnChainResolver;
|
|
82630
85377
|
exports.OnChainRevocationStorage = OnChainRevocationStorage;
|
|
82631
85378
|
exports.OnChainZKPVerifier = OnChainZKPVerifier;
|
|
85379
|
+
exports.OnchainIssuer = OnchainIssuer;
|
|
82632
85380
|
exports.PROTOCOL_CONSTANTS = constants;
|
|
82633
85381
|
exports.PackageManager = PackageManager;
|
|
82634
85382
|
exports.Parser = Parser;
|
|
@@ -82682,6 +85430,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
82682
85430
|
exports.checkQueryRequest = checkQueryRequest;
|
|
82683
85431
|
exports.circuitValidator = circuitValidator;
|
|
82684
85432
|
exports.comparatorOptions = comparatorOptions;
|
|
85433
|
+
exports.convertPaymentAmount = convertPaymentAmount;
|
|
82685
85434
|
exports.core = index$1;
|
|
82686
85435
|
exports.createAuthorizationRequest = createAuthorizationRequest;
|
|
82687
85436
|
exports.createAuthorizationRequestWithMessage = createAuthorizationRequestWithMessage;
|
|
@@ -82712,6 +85461,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
82712
85461
|
exports.findCredentialType = findCredentialType;
|
|
82713
85462
|
exports.findValue = findValue;
|
|
82714
85463
|
exports.generateProfileDID = generateProfileDID;
|
|
85464
|
+
exports.getERC20Decimals = getERC20Decimals;
|
|
82715
85465
|
exports.getFieldSlotIndex = getFieldSlotIndex;
|
|
82716
85466
|
exports.getKMSIdByAuthCredential = getKMSIdByAuthCredential;
|
|
82717
85467
|
exports.getNodeAuxValue = getNodeAuxValue;
|