@windingtree/org.id-core
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -6,1 +6,3 @@ import type { Signer } from 'ethers'; | ||
export declare const createOrgId: (contract: OrgIdBaseContract, salt: string, orgJsonUri: string, orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number) => Promise<OrgIdData | null>; | ||
export declare const createOrgIdWithDelegates: (contract: OrgIdBaseContract, salt: string, orgJsonUri: string, delegates: string[], orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number) => Promise<OrgIdData | null>; | ||
export declare const createOrgIdFor: (contract: OrgIdBaseContract, orgId: string, orgJsonUri: string, orgIdOwner: string, delegates: string[], creator: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number) => Promise<OrgIdData | null>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createOrgId = void 0; | ||
exports.createOrgIdFor = exports.createOrgIdWithDelegates = exports.createOrgId = void 0; | ||
const org_id_utils_1 = require("@windingtree/org.id-utils"); | ||
@@ -30,2 +30,48 @@ const getOrgId_1 = require("./getOrgId"); | ||
exports.createOrgId = createOrgId; | ||
const createOrgIdWithDelegates = async (contract, salt, orgJsonUri, delegates, orgIdOwner, overrides, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
transactionHashCb = () => { }, confirmations) => { | ||
if (!org_id_utils_1.regexp.bytes32.exec(salt)) { | ||
throw new Error(`createOrgIdWithDelegates: Invalid ORGiD salt: ${salt}`); | ||
} | ||
if (!orgJsonUri || orgJsonUri === '') { | ||
throw new Error(`createOrgIdWithDelegates: Invalid orgJsonUri value: ${orgJsonUri}`); | ||
} | ||
const receipt = await (0, sendHelper_1.sendHelper)(contract, 'createOrgId(bytes32,string,string[])', [ | ||
salt, | ||
orgJsonUri, | ||
delegates | ||
], orgIdOwner, overrides, transactionHashCb, confirmations); | ||
if (!receipt.events) { | ||
throw new Error('createOrgIdWithDelegates: Unable to found events in the transaction receipt'); | ||
} | ||
const event = receipt.events.filter(e => e.event === 'OrgIdCreated')[0]; | ||
if (!event.args) { | ||
throw new Error('createOrgIdWithDelegates: Unable extract OrgIdCreated event data'); | ||
} | ||
return (0, getOrgId_1.getOrgId)(contract, event.args.orgId); | ||
}; | ||
exports.createOrgIdWithDelegates = createOrgIdWithDelegates; | ||
const createOrgIdFor = async (contract, orgId, orgJsonUri, orgIdOwner, delegates, creator, overrides, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
transactionHashCb = () => { }, confirmations) => { | ||
if (!orgJsonUri || orgJsonUri === '') { | ||
throw new Error(`createOrgIdFor: Invalid orgJsonUri value: ${orgJsonUri}`); | ||
} | ||
const receipt = await (0, sendHelper_1.sendHelper)(contract, 'createOrgIdFor(bytes32,string,address,string[])', [ | ||
orgId, | ||
orgJsonUri, | ||
orgIdOwner, | ||
delegates | ||
], creator, overrides, transactionHashCb, confirmations); | ||
if (!receipt.events) { | ||
throw new Error('createOrgIdFor: Unable to found events in the transaction receipt'); | ||
} | ||
const event = receipt.events.filter(e => e.event === 'OrgIdCreated')[0]; | ||
if (!event.args) { | ||
throw new Error('createOrgIdFor: Unable extract OrgIdCreated event data'); | ||
} | ||
return (0, getOrgId_1.getOrgId)(contract, event.args.orgId); | ||
}; | ||
exports.createOrgIdFor = createOrgIdFor; | ||
//# sourceMappingURL=createOrgId.js.map |
@@ -5,17 +5,27 @@ "use strict"; | ||
const getOrgIds = async (contract, cursor, count = 10) => { | ||
if (typeof cursor === 'number' && cursor < 0) { | ||
if (cursor === undefined) { | ||
cursor = 1; | ||
} | ||
else if (typeof cursor !== 'number' || cursor < 1) { | ||
throw new Error(`getOrgIds: Invalid cursor: ${cursor}`); | ||
} | ||
if (typeof count === 'number' && count < 1) { | ||
throw new Error(`getOrgIds: Invalid count: ${cursor}`); | ||
if (typeof count !== 'number' || count < 1) { | ||
throw new Error(`getOrgIds: Invalid count: ${count}`); | ||
} | ||
if (typeof count === 'number' && cursor === undefined) { | ||
cursor = 0; | ||
const totalSupply = await contract['totalSupply()'](); | ||
const total = totalSupply.toNumber(); | ||
if (cursor > total) { | ||
return []; | ||
} | ||
if (typeof cursor === 'number') { | ||
return contract['getOrgIds(uint256,uint256)'](cursor, count); | ||
const targetIds = []; | ||
for (let i = cursor; i <= total; i++) { | ||
targetIds.push(i); | ||
if (targetIds.length >= count) { | ||
break; | ||
} | ||
} | ||
return contract['getOrgIds()'](); | ||
const orgIds = await Promise.all(targetIds.map(id => contract.getOrgId(id))); | ||
return orgIds.map(o => o.orgId); | ||
}; | ||
exports.getOrgIds = getOrgIds; | ||
//# sourceMappingURL=getOrgIds.js.map |
@@ -6,1 +6,2 @@ import type { Signer } from 'ethers'; | ||
export declare const setOrgJson: (contract: OrgIdBaseContract, orgIdHash: string, orgJsonUri: string, orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number) => Promise<OrgIdData | null>; | ||
export declare const setOrgJsonWithDelegates: (contract: OrgIdBaseContract, orgIdHash: string, orgJsonUri: string, delegates: string[], orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number) => Promise<OrgIdData | null>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setOrgJson = void 0; | ||
exports.setOrgJsonWithDelegates = exports.setOrgJson = void 0; | ||
const org_id_utils_1 = require("@windingtree/org.id-utils"); | ||
@@ -34,2 +34,30 @@ const getOrgId_1 = require("./getOrgId"); | ||
exports.setOrgJson = setOrgJson; | ||
const setOrgJsonWithDelegates = async (contract, orgIdHash, orgJsonUri, delegates, orgIdOwner, overrides, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
transactionHashCb = () => { }, confirmations) => { | ||
if (!org_id_utils_1.regexp.bytes32.exec(orgIdHash)) { | ||
throw new Error(`setOrgJsonWithDelegates: Invalid ORGiD hash: ${orgIdHash}`); | ||
} | ||
if (!orgJsonUri || orgJsonUri === '') { | ||
throw new Error(`setOrgJsonWithDelegates: Invalid orgJsonUri value: ${orgJsonUri}`); | ||
} | ||
const orgId = await (0, getOrgId_1.getOrgId)(contract, orgIdHash); | ||
if (!orgId) { | ||
throw new Error(`setOrgJsonWithDelegates: ORGiD not found: ${orgIdHash}`); | ||
} | ||
const receipt = await (0, sendHelper_1.sendHelper)(contract, 'setOrgJson(bytes32,string,string[])', [ | ||
orgIdHash, | ||
orgJsonUri, | ||
delegates | ||
], orgIdOwner, overrides, transactionHashCb, confirmations); | ||
if (!receipt.events) { | ||
throw new Error('setOrgJsonWithDelegates: Unable to found events in the transaction receipt'); | ||
} | ||
const event = receipt.events.filter(e => e.event === 'OrgJsonUriChanged')[0]; | ||
if (!event.args) { | ||
throw new Error('setOrgJsonWithDelegates: Unable extract OrgJsonUriChanged event data'); | ||
} | ||
return (0, getOrgId_1.getOrgId)(contract, event.args.orgId); | ||
}; | ||
exports.setOrgJsonWithDelegates = setOrgJsonWithDelegates; | ||
//# sourceMappingURL=setOrgJson.js.map |
@@ -13,3 +13,6 @@ import type { BigNumber, Signer, providers } from 'ethers'; | ||
createOrgId(salt: string, orgJsonUri: string, orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number): Promise<OrgIdData | null>; | ||
createOrgIdWithDelegates(salt: string, orgJsonUri: string, delegates: string[], orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number): Promise<OrgIdData | null>; | ||
createOrgIdFor(orgId: string, orgJsonUri: string, orgIdOwner: string, delegates: string[], creator: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number): Promise<OrgIdData | null>; | ||
setOrgJson(orgIdHash: string, orgJsonUri: string, orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number): Promise<OrgIdData | null>; | ||
setOrgJsonWithDelegates(orgIdHash: string, orgJsonUri: string, delegates: string[], orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number): Promise<OrgIdData | null>; | ||
transferOrgIdOwnership(orgIdHash: string, newOrgIdOwner: string, orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number): Promise<OrgIdData | null>; | ||
@@ -16,0 +19,0 @@ addDelegates(orgIdHash: string, dids: string[], orgIdOwner: Signer, overrides?: MethodOverrides, transactionHashCb?: TxHashCallbackFn, confirmations?: number): Promise<AddDelegatesResult>; |
@@ -50,2 +50,12 @@ "use strict"; | ||
} | ||
createOrgIdWithDelegates(salt, orgJsonUri, delegates, orgIdOwner, overrides, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
transactionHashCb = () => { }, confirmations) { | ||
return (0, createOrgId_1.createOrgIdWithDelegates)(this.contract, salt, orgJsonUri, delegates, orgIdOwner, overrides, transactionHashCb, confirmations); | ||
} | ||
createOrgIdFor(orgId, orgJsonUri, orgIdOwner, delegates, creator, overrides, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
transactionHashCb = () => { }, confirmations) { | ||
return (0, createOrgId_1.createOrgIdFor)(this.contract, orgId, orgJsonUri, orgIdOwner, delegates, creator, overrides, transactionHashCb, confirmations); | ||
} | ||
setOrgJson(orgIdHash, orgJsonUri, orgIdOwner, overrides, | ||
@@ -56,2 +66,7 @@ // eslint-disable-next-line @typescript-eslint/no-empty-function | ||
} | ||
setOrgJsonWithDelegates(orgIdHash, orgJsonUri, delegates, orgIdOwner, overrides, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
transactionHashCb = () => { }, confirmations) { | ||
return (0, setOrgJson_1.setOrgJsonWithDelegates)(this.contract, orgIdHash, orgJsonUri, delegates, orgIdOwner, overrides, transactionHashCb, confirmations); | ||
} | ||
transferOrgIdOwnership(orgIdHash, newOrgIdOwner, orgIdOwner, overrides, | ||
@@ -58,0 +73,0 @@ // eslint-disable-next-line @typescript-eslint/no-empty-function |
@@ -19,3 +19,3 @@ "use strict"; | ||
const gasAmount = await contractWithSigner | ||
.estimateGas[method](...args); | ||
.estimateGas[method].apply(contractWithSigner, args); | ||
// Validate available gas | ||
@@ -22,0 +22,0 @@ if (overrides && overrides.gasPrice) { |
{ | ||
"name": "@windingtree/org.id-core", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Core ORGiD Javascript library", | ||
@@ -41,4 +41,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@windingtree/org.id": "3.0.1", | ||
"@windingtree/org.id-utils": "^1.2.3", | ||
"@windingtree/org.id": "3.1.1", | ||
"@windingtree/org.id-utils": "^1.2.4", | ||
"ethers": "5.7.1" | ||
@@ -54,3 +54,3 @@ }, | ||
"@typescript-eslint/parser": "5.40.1", | ||
"@windingtree/org.id-test-setup": "^1.2.3", | ||
"@windingtree/org.id-test-setup": "^1.2.4", | ||
"chai": "4.3.6", | ||
@@ -66,3 +66,3 @@ "chai-as-promised": "7.1.1", | ||
}, | ||
"gitHead": "aeffaa8c84b8204c7bfcd8babc64468f97d1cc57" | ||
"gitHead": "b91c58d8462eeba1ce96394e14bdfb26bba45206" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54557
621
+ Added@openzeppelin/contracts-upgradeable@4.7.3(transitive)
+ Added@windingtree/org.id@3.1.1(transitive)
- Removed@openzeppelin/contracts-upgradeable@4.3.2(transitive)
- Removed@windingtree/org.id@3.0.1(transitive)
Updated@windingtree/org.id@3.1.1