@nevermined-io/core-kit 0.4.6 → 0.5.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/Instantiable.abstract.js +15 -13
- package/dist/Instantiable.abstract.js.map +1 -0
- package/dist/artifacts/generated.d.ts +174 -40
- package/dist/artifacts/generated.d.ts.map +1 -1
- package/dist/artifacts/generated.js +22805 -7111
- package/dist/artifacts/generated.js.map +1 -0
- package/dist/contracts/AccessManager.js +12 -3
- package/dist/contracts/AccessManager.js.map +1 -0
- package/dist/contracts/AssetRegistry.d.ts +1 -0
- package/dist/contracts/AssetRegistry.d.ts.map +1 -1
- package/dist/contracts/AssetRegistry.js +134 -69
- package/dist/contracts/AssetRegistry.js.map +1 -0
- package/dist/contracts/ContractBase.d.ts.map +1 -1
- package/dist/contracts/ContractBase.js +173 -140
- package/dist/contracts/ContractBase.js.map +1 -0
- package/dist/contracts/ContractsApi.js +6 -54
- package/dist/contracts/ContractsApi.js.map +1 -0
- package/dist/contracts/CryptoTemplateBase.js +23 -11
- package/dist/contracts/CryptoTemplateBase.js.map +1 -0
- package/dist/contracts/FiatPaymentTemplate.js +9 -1
- package/dist/contracts/FiatPaymentTemplate.js.map +1 -0
- package/dist/contracts/FiatSettlementCondition.js +8 -1
- package/dist/contracts/FiatSettlementCondition.js.map +1 -0
- package/dist/contracts/FixedPaymentTemplate.js +42 -10
- package/dist/contracts/FixedPaymentTemplate.js.map +1 -0
- package/dist/contracts/NFT1155Base.js +48 -12
- package/dist/contracts/NFT1155Base.js.map +1 -0
- package/dist/contracts/NFT1155Credits.js +2 -0
- package/dist/contracts/NFT1155Credits.js.map +1 -0
- package/dist/contracts/NFT1155ExpirableCredits.js +26 -6
- package/dist/contracts/NFT1155ExpirableCredits.js.map +1 -0
- package/dist/contracts/NVMConfig.js +2 -0
- package/dist/contracts/NVMConfig.js.map +1 -0
- package/dist/contracts/PayAsYouGoTemplate.js +36 -10
- package/dist/contracts/PayAsYouGoTemplate.js.map +1 -0
- package/dist/contracts/ProtocolStandardFees.js +7 -1
- package/dist/contracts/ProtocolStandardFees.js.map +1 -0
- package/dist/contracts/Roles.js +2 -0
- package/dist/contracts/Roles.js.map +1 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/errors/NeverminedErrors.js +27 -26
- package/dist/errors/NeverminedErrors.js.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/models/AgentX402AccessToken.js +78 -46
- package/dist/models/AgentX402AccessToken.js.map +1 -0
- package/dist/models/Logger.js +12 -12
- package/dist/models/Logger.js.map +1 -0
- package/dist/models/NeverminedOptions.d.ts +3 -3
- package/dist/models/NeverminedOptions.d.ts.map +1 -1
- package/dist/models/NeverminedOptions.js +3 -28
- package/dist/models/NeverminedOptions.js.map +1 -0
- package/dist/models/NvmApiKey.js +96 -147
- package/dist/models/NvmApiKey.js.map +1 -0
- package/dist/models/Transactions.js +3 -1
- package/dist/models/Transactions.js.map +1 -0
- package/dist/models/index.js +2 -0
- package/dist/models/index.js.map +1 -0
- package/dist/nevermined/Nevermined.js +20 -42
- package/dist/nevermined/Nevermined.js.map +1 -0
- package/dist/nevermined/api/PaymentsApi.js +38 -43
- package/dist/nevermined/api/PaymentsApi.js.map +1 -0
- package/dist/nevermined/api/ServicesApi.js +7 -15
- package/dist/nevermined/api/ServicesApi.js.map +1 -0
- package/dist/nevermined/api/UtilsApi.js +7 -19
- package/dist/nevermined/api/UtilsApi.js.map +1 -0
- package/dist/nevermined/index.js +2 -0
- package/dist/nevermined/index.js.map +1 -0
- package/dist/nevermined/utils/AgentUtils.js +25 -23
- package/dist/nevermined/utils/AgentUtils.js.map +1 -0
- package/dist/nevermined/utils/AnvilHelpers.js +34 -19
- package/dist/nevermined/utils/AnvilHelpers.js.map +1 -0
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts +4 -4
- package/dist/nevermined/utils/BlockchainViemUtils.js +102 -108
- package/dist/nevermined/utils/BlockchainViemUtils.js.map +1 -0
- package/dist/nevermined/utils/JwtUtils.js +33 -28
- package/dist/nevermined/utils/JwtUtils.js.map +1 -0
- package/dist/nevermined/utils/SignatureUtils.js +23 -27
- package/dist/nevermined/utils/SignatureUtils.js.map +1 -0
- package/dist/nevermined/utils/WebServiceConnector.js +18 -20
- package/dist/nevermined/utils/WebServiceConnector.js.map +1 -0
- package/dist/nevermined/utils/ZeroDevPolicies.js +115 -75
- package/dist/nevermined/utils/ZeroDevPolicies.js.map +1 -0
- package/dist/nevermined/utils/index.js +2 -0
- package/dist/nevermined/utils/index.js.map +1 -0
- package/dist/services/Api.js +11 -5
- package/dist/services/Api.js.map +1 -0
- package/dist/services/Profiles.js +15 -20
- package/dist/services/Profiles.js.map +1 -0
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -0
- package/dist/utils/ConversionTypeHelpers.js +13 -6
- package/dist/utils/ConversionTypeHelpers.js.map +1 -0
- package/dist/utils/DeploymentInfo.js +12 -7
- package/dist/utils/DeploymentInfo.js.map +1 -0
- package/dist/utils/Network.js +27 -19
- package/dist/utils/Network.js.map +1 -0
- package/dist/utils/helpers.js +42 -31
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +17 -1
|
@@ -7,9 +7,18 @@ export class AccessManager extends ContractBase {
|
|
|
7
7
|
return accessManager;
|
|
8
8
|
}
|
|
9
9
|
async hasRole(roleId, address) {
|
|
10
|
-
return this.contract.read.hasRole([
|
|
10
|
+
return this.contract.read.hasRole([
|
|
11
|
+
roleId,
|
|
12
|
+
address
|
|
13
|
+
]);
|
|
11
14
|
}
|
|
12
|
-
async grantRole({ address, roleId, executionDelay, owner, txParams
|
|
13
|
-
return this.send('grantRole', owner, [
|
|
15
|
+
async grantRole({ address, roleId, executionDelay, owner, txParams }) {
|
|
16
|
+
return this.send('grantRole', owner, [
|
|
17
|
+
roleId,
|
|
18
|
+
address,
|
|
19
|
+
executionDelay ?? 0
|
|
20
|
+
], txParams);
|
|
14
21
|
}
|
|
15
22
|
}
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=AccessManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/contracts/AccessManager.ts"],"sourcesContent":["import { Account, Address, TransactionReceipt } from 'viem'\nimport { accessManagerConfig } from '../artifacts/generated.js'\nimport { InstantiableConfig } from '../Instantiable.abstract.js'\nimport { ContractBase } from './ContractBase.js'\nimport { SmartAccount, UserOperationReceipt } from 'viem/account-abstraction'\nimport { TxParameters } from '../models/Transactions.js'\n\nexport class AccessManager extends ContractBase {\n public static override async getInstance(config: InstantiableConfig): Promise<AccessManager> {\n const accessManager: AccessManager = new AccessManager(\n 'AccessManager',\n accessManagerConfig.address,\n )\n await accessManager.init(config, accessManagerConfig)\n return accessManager\n }\n\n public async hasRole(roleId: bigint, address: Address): Promise<[boolean, bigint]> {\n return this.contract.read.hasRole([roleId, address])\n }\n public async grantRole({\n address,\n roleId,\n executionDelay,\n owner,\n txParams,\n }: {\n address: Address\n roleId: bigint\n executionDelay?: number\n owner: Account | SmartAccount\n txParams?: TxParameters\n }): Promise<TransactionReceipt | UserOperationReceipt> {\n return this.send('grantRole', owner, [roleId, address, executionDelay ?? 0], txParams)\n }\n}\n"],"names":["accessManagerConfig","ContractBase","AccessManager","getInstance","config","accessManager","address","init","hasRole","roleId","contract","read","grantRole","executionDelay","owner","txParams","send"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,4BAA2B;AAE/D,SAASC,YAAY,QAAQ,oBAAmB;AAIhD,OAAO,MAAMC,sBAAsBD;IACjC,aAA6BE,YAAYC,MAA0B,EAA0B;QAC3F,MAAMC,gBAA+B,IAAIH,cACvC,iBACAF,oBAAoBM,OAAO;QAE7B,MAAMD,cAAcE,IAAI,CAACH,QAAQJ;QACjC,OAAOK;IACT;IAEA,MAAaG,QAAQC,MAAc,EAAEH,OAAgB,EAA8B;QACjF,OAAO,IAAI,CAACI,QAAQ,CAACC,IAAI,CAACH,OAAO,CAAC;YAACC;YAAQH;SAAQ;IACrD;IACA,MAAaM,UAAU,EACrBN,OAAO,EACPG,MAAM,EACNI,cAAc,EACdC,KAAK,EACLC,QAAQ,EAOT,EAAsD;QACrD,OAAO,IAAI,CAACC,IAAI,CAAC,aAAaF,OAAO;YAACL;YAAQH;YAASO,kBAAkB;SAAE,EAAEE;IAC/E;AACF"}
|
|
@@ -67,6 +67,7 @@ export declare class AssetRegistry extends ContractBase {
|
|
|
67
67
|
templateAddress?: Address;
|
|
68
68
|
};
|
|
69
69
|
creditsConfig: {
|
|
70
|
+
proofRequired: boolean;
|
|
70
71
|
isRedemptionAmountFixed: boolean;
|
|
71
72
|
redemptionType: import("@nevermined-io/commons").RedemptionType;
|
|
72
73
|
onchainMirror: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetRegistry.d.ts","sourceRoot":"","sources":["../../src/contracts/AssetRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACnF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAa,kBAAkB,EAAe,MAAM,MAAM,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAU7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"AssetRegistry.d.ts","sourceRoot":"","sources":["../../src/contracts/AssetRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE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OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAQhC;;;;;;OAMG;IACU,6BAA6B,CACxC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;CAOjC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isAddress, zeroAddress } from 'viem';
|
|
2
|
-
import { assetsRegistryConfig, nft1155CreditsAddress, nft1155ExpirableCreditsV2Address, oneTimeCreatorHookAddress, payAsYouGoTemplateAddress, protocolStandardFeesAddress
|
|
2
|
+
import { assetsRegistryConfig, nft1155CreditsAddress, nft1155ExpirableCreditsV2Address, oneTimeCreatorHookAddress, payAsYouGoTemplateAddress, protocolStandardFeesAddress } from '../artifacts/generated.js';
|
|
3
3
|
import { AgentNotFound, PlanNotFound } from '../errors/NeverminedErrors.js';
|
|
4
4
|
import { toAgentId, zeroX } from '../utils/ConversionTypeHelpers.js';
|
|
5
5
|
import { ContractBase } from './ContractBase.js';
|
|
@@ -10,19 +10,26 @@ export class AssetRegistry extends ContractBase {
|
|
|
10
10
|
return assetRegistry;
|
|
11
11
|
}
|
|
12
12
|
async hashAgentId(seed, owner) {
|
|
13
|
-
return this.contract.read.hashAgentId([
|
|
13
|
+
return this.contract.read.hashAgentId([
|
|
14
|
+
seed,
|
|
15
|
+
owner
|
|
16
|
+
]);
|
|
14
17
|
}
|
|
15
18
|
async getAgent(agentId) {
|
|
16
|
-
const didAgent = await this.contract.read.getAgent([
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const didAgent = await this.contract.read.getAgent([
|
|
20
|
+
toAgentId(agentId)
|
|
21
|
+
]);
|
|
22
|
+
if (didAgent.lastUpdated != 0) return didAgent;
|
|
23
|
+
else throw new AgentNotFound(`Agent with id ${agentId} not found`);
|
|
21
24
|
}
|
|
22
|
-
async register({ seed, url, plans, owner, txParams
|
|
23
|
-
return this.send('register', owner, [
|
|
25
|
+
async register({ seed, url, plans, owner, txParams }) {
|
|
26
|
+
return this.send('register', owner, [
|
|
27
|
+
zeroX(seed),
|
|
28
|
+
url,
|
|
29
|
+
plans
|
|
30
|
+
], txParams);
|
|
24
31
|
}
|
|
25
|
-
async createPayAsYouGoPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams
|
|
32
|
+
async createPayAsYouGoPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams }) {
|
|
26
33
|
priceConfig.templateAddress = payAsYouGoTemplateAddress;
|
|
27
34
|
return this.createPlan({
|
|
28
35
|
priceConfig,
|
|
@@ -33,62 +40,97 @@ export class AssetRegistry extends ContractBase {
|
|
|
33
40
|
isTrialPlan,
|
|
34
41
|
organizationCryptoFee,
|
|
35
42
|
organizationCryptoWallet,
|
|
36
|
-
txParams
|
|
43
|
+
txParams
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
|
-
async createPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams
|
|
46
|
+
async createPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams }) {
|
|
40
47
|
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
41
48
|
if (isTrialPlan) {
|
|
42
|
-
const hooks = [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
const hooks = [
|
|
50
|
+
oneTimeCreatorHookAddress
|
|
51
|
+
];
|
|
52
|
+
return this.send('createPlanWithHooks', owner, [
|
|
53
|
+
_config.priceConfig,
|
|
54
|
+
_config.creditsConfig,
|
|
55
|
+
hooks,
|
|
56
|
+
nonce
|
|
57
|
+
], txParams);
|
|
58
|
+
} else {
|
|
59
|
+
return this.send('createPlan', owner, [
|
|
60
|
+
_config.priceConfig,
|
|
61
|
+
_config.creditsConfig,
|
|
62
|
+
nonce
|
|
63
|
+
], txParams);
|
|
47
64
|
}
|
|
48
65
|
}
|
|
49
|
-
async registerAgentAndPlan({ seed, url, priceConfig, creditsConfig, owner, addFees = true, organizationCryptoFee, organizationCryptoWallet, txParams
|
|
66
|
+
async registerAgentAndPlan({ seed, url, priceConfig, creditsConfig, owner, addFees = true, organizationCryptoFee, organizationCryptoWallet, txParams }) {
|
|
50
67
|
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
51
|
-
return this.send('registerAgentAndPlan', owner, [
|
|
68
|
+
return this.send('registerAgentAndPlan', owner, [
|
|
69
|
+
zeroX(seed),
|
|
70
|
+
url,
|
|
71
|
+
_config.priceConfig,
|
|
72
|
+
_config.creditsConfig
|
|
73
|
+
], txParams);
|
|
52
74
|
}
|
|
53
75
|
async getPlan(planId) {
|
|
54
|
-
const plan = this.contract.read.getPlan([
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
const plan = this.contract.read.getPlan([
|
|
77
|
+
planId
|
|
78
|
+
]);
|
|
79
|
+
if (plan.lastUpdated != 0) return plan;
|
|
80
|
+
else throw new PlanNotFound('Plan not registered');
|
|
59
81
|
}
|
|
60
|
-
async getPlanTotalPrice({ planId, plan
|
|
82
|
+
async getPlanTotalPrice({ planId, plan }) {
|
|
61
83
|
if (!plan && !planId) {
|
|
62
84
|
throw new PlanNotFound('Plan not registered');
|
|
63
85
|
}
|
|
64
86
|
if (!plan) {
|
|
65
87
|
plan = await this.getPlan(planId);
|
|
66
88
|
}
|
|
67
|
-
if (plan.lastUpdated === 0n)
|
|
68
|
-
|
|
69
|
-
return plan.price.amounts.reduce((a, b) => a + b, 0n);
|
|
89
|
+
if (plan.lastUpdated === 0n) throw new PlanNotFound('Plan not registered');
|
|
90
|
+
return plan.price.amounts.reduce((a, b)=>a + b, 0n);
|
|
70
91
|
}
|
|
71
92
|
async planExists(id) {
|
|
72
|
-
return this.contract.read.planExists([
|
|
93
|
+
return this.contract.read.planExists([
|
|
94
|
+
id
|
|
95
|
+
]);
|
|
73
96
|
}
|
|
74
97
|
async addPlanToAgent(planId, agentId, owner, txParams) {
|
|
75
|
-
return this.send('addPlanToAgent', owner, [
|
|
98
|
+
return this.send('addPlanToAgent', owner, [
|
|
99
|
+
toAgentId(agentId),
|
|
100
|
+
planId
|
|
101
|
+
], txParams);
|
|
76
102
|
}
|
|
77
103
|
async removePlanFromAgent(planId, agentId, owner, txParams) {
|
|
78
|
-
return this.send('removePlanFromAgent', owner, [
|
|
104
|
+
return this.send('removePlanFromAgent', owner, [
|
|
105
|
+
toAgentId(agentId),
|
|
106
|
+
planId
|
|
107
|
+
], txParams);
|
|
79
108
|
}
|
|
80
109
|
async planConfigPreFilter(priceConfig, creditsConfig, includeFees = true, organizationCryptoFee, organizationCryptoWallet) {
|
|
81
|
-
const _priceConfig = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
110
|
+
const _priceConfig = {
|
|
111
|
+
...priceConfig
|
|
112
|
+
};
|
|
113
|
+
// Compat shim: the contract ABI in `artifacts/generated.ts` still names
|
|
114
|
+
// the credits-config slot `proofRequired` (legacy EIP-712 signed-burn
|
|
115
|
+
// flag, see nvm-monorepo#1253). The TS interface renamed it to
|
|
116
|
+
// `onchainMirror` in PR #1277. Viem looks up tuple components by name
|
|
117
|
+
// when ABI-encoding, so without this alias every downstream
|
|
118
|
+
// `contract.read.*([creditsConfig, ...])` call resolves the slot to
|
|
119
|
+
// `undefined` and throws "Invalid boolean value: 'undefined'". Inject
|
|
120
|
+
// the alias here so every method that runs through `planConfigPreFilter`
|
|
121
|
+
// (`createPlan`, `hashPlanId`, `registerAgentAndPlan`,
|
|
122
|
+
// `includeFeesInPaymentsDistribution` via line 244) sees a config
|
|
123
|
+
// viem can encode. Drop once the contract artifact is regenerated.
|
|
124
|
+
const _creditsConfig = {
|
|
125
|
+
...creditsConfig,
|
|
126
|
+
proofRequired: creditsConfig.onchainMirror
|
|
127
|
+
};
|
|
128
|
+
if (!priceConfig.feeController || !isAddress(priceConfig.feeController)) _priceConfig.feeController = protocolStandardFeesAddress;
|
|
129
|
+
if (!priceConfig.templateAddress || !isAddress(priceConfig.templateAddress)) _priceConfig.templateAddress = zeroAddress;
|
|
87
130
|
if (!creditsConfig.nftAddress || !isAddress(creditsConfig.nftAddress)) {
|
|
88
131
|
if (creditsConfig.durationSecs > 0n) {
|
|
89
132
|
_creditsConfig.nftAddress = nft1155ExpirableCreditsV2Address;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
133
|
+
} else {
|
|
92
134
|
_creditsConfig.nftAddress = nft1155CreditsAddress;
|
|
93
135
|
}
|
|
94
136
|
}
|
|
@@ -101,55 +143,78 @@ export class AssetRegistry extends ContractBase {
|
|
|
101
143
|
_priceConfig.amounts.push(organizationCryptoFee);
|
|
102
144
|
_priceConfig.receivers.push(organizationCryptoWallet);
|
|
103
145
|
}
|
|
104
|
-
return {
|
|
146
|
+
return {
|
|
147
|
+
priceConfig: _priceConfig,
|
|
148
|
+
creditsConfig: _creditsConfig
|
|
149
|
+
};
|
|
105
150
|
}
|
|
106
151
|
async hashPlanId(_priceConfig, _creditsConfig, owner, addFees = true, nonce = 0n, organizationCryptoFee, organizationCryptoWallet) {
|
|
107
152
|
const _config = await this.planConfigPreFilter(_priceConfig, _creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
153
|
+
// The generated ABI carries both the legacy 3-arg `hashPlanId(_priceConfig,
|
|
154
|
+
// _creditsConfig, _creator)` overload and the new 4-arg
|
|
155
|
+
// `hashPlanId(_priceConfig, _creditsConfig, _creator, _nonce)` overload.
|
|
156
|
+
// Viem's `getContract().read.<name>` proxy resolves overloads by NAME
|
|
157
|
+
// only — it picks the first matching ABI item without re-checking
|
|
158
|
+
// arity — so the 4-arg call below was being encoded against the 3-arg
|
|
159
|
+
// overload and erroring with `AbiEncodingLengthMismatchError: Expected
|
|
160
|
+
// length 3, Given length 4` (CI run 25872339578, core-kit e2e).
|
|
161
|
+
//
|
|
162
|
+
// Drop directly to `readContract` with an ABI restricted to the 4-arg
|
|
163
|
+
// function so there's only one possible match. Same effect as
|
|
164
|
+
// dropping the legacy overload from the artifact, but local to this
|
|
165
|
+
// call site (the artifact is regenerated by `pnpm generate:wagmi:*`
|
|
166
|
+
// from the protocol submodule, so a tree-side artifact edit would be
|
|
167
|
+
// wiped on the next codegen).
|
|
168
|
+
const hashPlanIdAbi = this.contract.abi.filter((item)=>item.type === 'function' && item.name === 'hashPlanId' && Array.isArray(item.inputs) && item.inputs.length === 4);
|
|
169
|
+
return await this.client.public.readContract({
|
|
170
|
+
address: this.address,
|
|
171
|
+
abi: hashPlanIdAbi,
|
|
172
|
+
functionName: 'hashPlanId',
|
|
173
|
+
args: [
|
|
174
|
+
_config.priceConfig,
|
|
175
|
+
_config.creditsConfig,
|
|
176
|
+
owner,
|
|
177
|
+
nonce
|
|
178
|
+
]
|
|
179
|
+
});
|
|
114
180
|
}
|
|
115
181
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
async areNeverminedFeesIncluded(priceConfig) {
|
|
182
|
+
* @notice Checks if Nevermined fees are included in the payment distribution
|
|
183
|
+
* @param _planId The ID of the plan to check
|
|
184
|
+
* @return bool True if Nevermined fees are properly included
|
|
185
|
+
*/ async areNeverminedFeesIncluded(priceConfig) {
|
|
121
186
|
return await this.contract.read.areNeverminedFeesIncluded([
|
|
122
187
|
priceConfig.amounts,
|
|
123
|
-
priceConfig.receivers
|
|
188
|
+
priceConfig.receivers
|
|
124
189
|
]);
|
|
125
190
|
}
|
|
126
191
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
async includeFeesInPaymentsDistribution(priceConfig, creditsConfig) {
|
|
192
|
+
* @notice Getting a payment distribution, it includes the Nevermined fees if not already included
|
|
193
|
+
* This method subsctracts the fees from the original amounts and adds a new entry for the fee recipient
|
|
194
|
+
* @param priceConfig The price configuration of the plan
|
|
195
|
+
* @param creditsConfig The credits configuration of the plan
|
|
196
|
+
* @return amounts Updated array of payment amounts including fees
|
|
197
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
198
|
+
*/ async includeFeesInPaymentsDistribution(priceConfig, creditsConfig) {
|
|
135
199
|
const result = await this.contract.read.includeFeesInPaymentsDistribution([
|
|
136
200
|
priceConfig,
|
|
137
|
-
creditsConfig
|
|
201
|
+
creditsConfig
|
|
138
202
|
]);
|
|
139
203
|
return result;
|
|
140
204
|
}
|
|
141
205
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
async addFeesToPaymentsDistribution(priceConfig, creditsConfig) {
|
|
206
|
+
* @notice Adds Nevermined fees to the payment distribution if not already included
|
|
207
|
+
* @param priceConfig The price configuration of the plan
|
|
208
|
+
* @param creditsConfig The credits configuration of the plan
|
|
209
|
+
* @return amounts Updated array of payment amounts including fees
|
|
210
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
211
|
+
*/ async addFeesToPaymentsDistribution(priceConfig, creditsConfig) {
|
|
149
212
|
const result = await this.contract.read.addFeesToPaymentsDistribution([
|
|
150
213
|
priceConfig,
|
|
151
|
-
creditsConfig
|
|
214
|
+
creditsConfig
|
|
152
215
|
]);
|
|
153
216
|
return result;
|
|
154
217
|
}
|
|
155
218
|
}
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=AssetRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/contracts/AssetRegistry.ts"],"sourcesContent":["import { CreditsConfig, DIDAgent, Plan, PriceConfig } from '@nevermined-io/commons'\nimport { Account, Address, isAddress, TransactionReceipt, zeroAddress } from 'viem'\nimport { SmartAccount, UserOperationReceipt } from 'viem/account-abstraction'\nimport {\n assetsRegistryConfig,\n nft1155CreditsAddress,\n nft1155ExpirableCreditsV2Address,\n oneTimeCreatorHookAddress,\n payAsYouGoTemplateAddress,\n protocolStandardFeesAddress,\n} from '../artifacts/generated.js'\nimport { AgentNotFound, PlanNotFound } from '../errors/NeverminedErrors.js'\nimport { InstantiableConfig } from '../Instantiable.abstract.js'\nimport { TxParameters } from '../models/Transactions.js'\nimport { toAgentId, zeroX } from '../utils/ConversionTypeHelpers.js'\nimport { ContractBase } from './ContractBase.js'\n\n/**\n * Loose structural type for the ABI items we filter in `hashPlanId` to\n * disambiguate the legacy 3-arg overload from the 4-arg one. Mirrors only\n * the fields we read, so it stays usable against the auto-generated tuple\n * type emitted by wagmi codegen without dragging in the full viem type.\n */\ntype AbiItemLike = {\n type: string\n name?: string\n inputs?: ReadonlyArray<unknown>\n}\n\nexport class AssetRegistry extends ContractBase {\n public static override async getInstance(config: InstantiableConfig): Promise<AssetRegistry> {\n const assetRegistry: AssetRegistry = new AssetRegistry(\n 'AssetRegistry',\n assetsRegistryConfig.address,\n )\n await assetRegistry.init(config, assetsRegistryConfig)\n return assetRegistry\n }\n\n public async hashAgentId(seed: string, owner: Address): Promise<bigint> {\n return this.contract.read.hashAgentId([seed, owner])\n }\n\n public async getAgent(agentId: string | bigint): Promise<DIDAgent> {\n const didAgent = await this.contract.read.getAgent([toAgentId(agentId)])\n if (didAgent.lastUpdated != 0) return didAgent\n else throw new AgentNotFound(`Agent with id ${agentId} not found`)\n }\n\n public async register({\n seed,\n url,\n plans,\n owner,\n txParams,\n }: {\n seed: string\n url: string\n plans: bigint[]\n owner: Account | SmartAccount\n txParams?: TxParameters\n }): Promise<TransactionReceipt | UserOperationReceipt> {\n return this.send('register', owner, [zeroX(seed), url, plans], txParams)\n }\n\n public async createPayAsYouGoPlan({\n priceConfig,\n creditsConfig,\n owner,\n nonce = 0n,\n addFees = true,\n isTrialPlan = false,\n organizationCryptoFee,\n organizationCryptoWallet,\n txParams,\n }: {\n priceConfig: PriceConfig\n creditsConfig: CreditsConfig\n owner: Account | SmartAccount\n nonce?: bigint\n addFees?: boolean\n isTrialPlan?: boolean\n organizationCryptoFee?: bigint\n organizationCryptoWallet?: string\n txParams?: TxParameters\n }): Promise<TransactionReceipt | UserOperationReceipt> {\n priceConfig.templateAddress = payAsYouGoTemplateAddress\n return this.createPlan({\n priceConfig,\n creditsConfig,\n owner,\n nonce,\n addFees,\n isTrialPlan,\n organizationCryptoFee,\n organizationCryptoWallet,\n txParams,\n })\n }\n\n public async createPlan({\n priceConfig,\n creditsConfig,\n owner,\n nonce = 0n,\n addFees = true,\n isTrialPlan = false,\n organizationCryptoFee,\n organizationCryptoWallet,\n txParams,\n }: {\n priceConfig: PriceConfig\n creditsConfig: CreditsConfig\n owner: Account | SmartAccount\n nonce?: bigint\n addFees?: boolean\n isTrialPlan?: boolean\n organizationCryptoFee?: bigint\n organizationCryptoWallet?: string\n txParams?: TxParameters\n }): Promise<TransactionReceipt | UserOperationReceipt> {\n const _config = await this.planConfigPreFilter(\n priceConfig,\n creditsConfig,\n addFees,\n organizationCryptoFee,\n organizationCryptoWallet,\n )\n\n if (isTrialPlan) {\n const hooks: Address[] = [oneTimeCreatorHookAddress]\n return this.send(\n 'createPlanWithHooks',\n owner,\n [_config.priceConfig, _config.creditsConfig, hooks, nonce],\n txParams,\n )\n } else {\n return this.send(\n 'createPlan',\n owner,\n [_config.priceConfig, _config.creditsConfig, nonce],\n txParams,\n )\n }\n }\n\n public async registerAgentAndPlan({\n seed,\n url,\n priceConfig,\n creditsConfig,\n owner,\n addFees = true,\n organizationCryptoFee,\n organizationCryptoWallet,\n txParams,\n }: {\n seed: string\n url: string\n priceConfig: PriceConfig\n creditsConfig: CreditsConfig\n owner: Account | SmartAccount\n addFees?: boolean\n organizationCryptoFee?: bigint\n organizationCryptoWallet?: string\n txParams?: TxParameters\n }): Promise<TransactionReceipt | UserOperationReceipt> {\n const _config = await this.planConfigPreFilter(\n priceConfig,\n creditsConfig,\n addFees,\n organizationCryptoFee,\n organizationCryptoWallet,\n )\n\n return this.send(\n 'registerAgentAndPlan',\n owner,\n [zeroX(seed), url, _config.priceConfig, _config.creditsConfig],\n txParams,\n )\n }\n\n public async getPlan(planId: bigint): Promise<Plan> {\n const plan = this.contract.read.getPlan([planId])\n if (plan.lastUpdated != 0) return plan\n else throw new PlanNotFound('Plan not registered')\n }\n\n public async getPlanTotalPrice({\n planId,\n plan,\n }: {\n planId?: bigint\n plan?: Plan\n }): Promise<bigint> {\n if (!plan && !planId) {\n throw new PlanNotFound('Plan not registered')\n }\n if (!plan) {\n plan = await this.getPlan(planId!)\n }\n\n if (plan.lastUpdated === 0n) throw new PlanNotFound('Plan not registered')\n return plan.price.amounts.reduce((a: bigint, b: bigint) => a + b, 0n)\n }\n\n public async planExists(id: bigint): Promise<boolean> {\n return this.contract.read.planExists([id])\n }\n\n public async addPlanToAgent(\n planId: bigint,\n agentId: string | bigint,\n owner: Account | SmartAccount,\n txParams?: TxParameters,\n ): Promise<TransactionReceipt | UserOperationReceipt> {\n return this.send('addPlanToAgent', owner, [toAgentId(agentId), planId], txParams)\n }\n\n public async removePlanFromAgent(\n planId: bigint,\n agentId: string | bigint,\n owner: Account | SmartAccount,\n txParams?: TxParameters,\n ): Promise<TransactionReceipt | UserOperationReceipt> {\n return this.send('removePlanFromAgent', owner, [toAgentId(agentId), planId], txParams)\n }\n\n public async planConfigPreFilter(\n priceConfig: PriceConfig,\n creditsConfig: CreditsConfig,\n includeFees = true,\n organizationCryptoFee?: bigint,\n organizationCryptoWallet?: string,\n ) {\n const _priceConfig = { ...priceConfig }\n // Compat shim: the contract ABI in `artifacts/generated.ts` still names\n // the credits-config slot `proofRequired` (legacy EIP-712 signed-burn\n // flag, see nvm-monorepo#1253). The TS interface renamed it to\n // `onchainMirror` in PR #1277. Viem looks up tuple components by name\n // when ABI-encoding, so without this alias every downstream\n // `contract.read.*([creditsConfig, ...])` call resolves the slot to\n // `undefined` and throws \"Invalid boolean value: 'undefined'\". Inject\n // the alias here so every method that runs through `planConfigPreFilter`\n // (`createPlan`, `hashPlanId`, `registerAgentAndPlan`,\n // `includeFeesInPaymentsDistribution` via line 244) sees a config\n // viem can encode. Drop once the contract artifact is regenerated.\n const _creditsConfig = {\n ...creditsConfig,\n proofRequired: creditsConfig.onchainMirror,\n }\n\n if (!priceConfig.feeController || !isAddress(priceConfig.feeController!))\n _priceConfig.feeController = protocolStandardFeesAddress\n\n if (!priceConfig.templateAddress || !isAddress(priceConfig.templateAddress!))\n _priceConfig.templateAddress = zeroAddress\n\n if (!creditsConfig.nftAddress || !isAddress(creditsConfig.nftAddress)) {\n if (creditsConfig.durationSecs > 0n) {\n _creditsConfig.nftAddress = nft1155ExpirableCreditsV2Address\n } else {\n _creditsConfig.nftAddress = nft1155CreditsAddress\n }\n }\n\n if (includeFees) {\n const fees = await this.includeFeesInPaymentsDistribution(_priceConfig, _creditsConfig)\n _priceConfig.amounts = fees[0]\n _priceConfig.receivers = fees[1]\n }\n\n if (organizationCryptoFee && organizationCryptoWallet) {\n _priceConfig.amounts.push(organizationCryptoFee)\n _priceConfig.receivers.push(organizationCryptoWallet)\n }\n\n return { priceConfig: _priceConfig, creditsConfig: _creditsConfig }\n }\n\n public async hashPlanId(\n _priceConfig: PriceConfig,\n _creditsConfig: CreditsConfig,\n owner: Address,\n addFees = true,\n nonce = 0n,\n organizationCryptoFee?: bigint,\n organizationCryptoWallet?: string,\n ): Promise<bigint> {\n const _config = await this.planConfigPreFilter(\n _priceConfig,\n _creditsConfig,\n addFees,\n organizationCryptoFee,\n organizationCryptoWallet,\n )\n // The generated ABI carries both the legacy 3-arg `hashPlanId(_priceConfig,\n // _creditsConfig, _creator)` overload and the new 4-arg\n // `hashPlanId(_priceConfig, _creditsConfig, _creator, _nonce)` overload.\n // Viem's `getContract().read.<name>` proxy resolves overloads by NAME\n // only — it picks the first matching ABI item without re-checking\n // arity — so the 4-arg call below was being encoded against the 3-arg\n // overload and erroring with `AbiEncodingLengthMismatchError: Expected\n // length 3, Given length 4` (CI run 25872339578, core-kit e2e).\n //\n // Drop directly to `readContract` with an ABI restricted to the 4-arg\n // function so there's only one possible match. Same effect as\n // dropping the legacy overload from the artifact, but local to this\n // call site (the artifact is regenerated by `pnpm generate:wagmi:*`\n // from the protocol submodule, so a tree-side artifact edit would be\n // wiped on the next codegen).\n const hashPlanIdAbi = (this.contract.abi as readonly AbiItemLike[]).filter(\n (item) =>\n item.type === 'function' &&\n item.name === 'hashPlanId' &&\n Array.isArray(item.inputs) &&\n item.inputs.length === 4,\n )\n return (await this.client.public.readContract({\n address: this.address,\n abi: hashPlanIdAbi,\n functionName: 'hashPlanId',\n args: [_config.priceConfig, _config.creditsConfig, owner, nonce],\n })) as bigint\n }\n\n /**\n * @notice Checks if Nevermined fees are included in the payment distribution\n * @param _planId The ID of the plan to check\n * @return bool True if Nevermined fees are properly included\n */\n public async areNeverminedFeesIncluded(priceConfig: PriceConfig): Promise<boolean> {\n return await this.contract.read.areNeverminedFeesIncluded([\n priceConfig.amounts,\n priceConfig.receivers,\n ])\n }\n\n /**\n * @notice Getting a payment distribution, it includes the Nevermined fees if not already included\n * This method subsctracts the fees from the original amounts and adds a new entry for the fee recipient\n * @param priceConfig The price configuration of the plan\n * @param creditsConfig The credits configuration of the plan\n * @return amounts Updated array of payment amounts including fees\n * @return receivers Updated array of payment receivers including fee recipient\n */\n public async includeFeesInPaymentsDistribution(\n priceConfig: PriceConfig,\n creditsConfig: CreditsConfig,\n ): Promise<[bigint[], string[]]> {\n const result = await this.contract.read.includeFeesInPaymentsDistribution([\n priceConfig,\n creditsConfig,\n ])\n return result\n }\n\n /**\n * @notice Adds Nevermined fees to the payment distribution if not already included\n * @param priceConfig The price configuration of the plan\n * @param creditsConfig The credits configuration of the plan\n * @return amounts Updated array of payment amounts including fees\n * @return receivers Updated array of payment receivers including fee recipient\n */\n public async addFeesToPaymentsDistribution(\n priceConfig: PriceConfig,\n creditsConfig: CreditsConfig,\n ): Promise<[bigint[], string[]]> {\n const result = await this.contract.read.addFeesToPaymentsDistribution([\n priceConfig,\n creditsConfig,\n ])\n return result\n }\n}\n"],"names":["isAddress","zeroAddress","assetsRegistryConfig","nft1155CreditsAddress","nft1155ExpirableCreditsV2Address","oneTimeCreatorHookAddress","payAsYouGoTemplateAddress","protocolStandardFeesAddress","AgentNotFound","PlanNotFound","toAgentId","zeroX","ContractBase","AssetRegistry","getInstance","config","assetRegistry","address","init","hashAgentId","seed","owner","contract","read","getAgent","agentId","didAgent","lastUpdated","register","url","plans","txParams","send","createPayAsYouGoPlan","priceConfig","creditsConfig","nonce","addFees","isTrialPlan","organizationCryptoFee","organizationCryptoWallet","templateAddress","createPlan","_config","planConfigPreFilter","hooks","registerAgentAndPlan","getPlan","planId","plan","getPlanTotalPrice","price","amounts","reduce","a","b","planExists","id","addPlanToAgent","removePlanFromAgent","includeFees","_priceConfig","_creditsConfig","proofRequired","onchainMirror","feeController","nftAddress","durationSecs","fees","includeFeesInPaymentsDistribution","receivers","push","hashPlanId","hashPlanIdAbi","abi","filter","item","type","name","Array","isArray","inputs","length","client","public","readContract","functionName","args","areNeverminedFeesIncluded","result","addFeesToPaymentsDistribution"],"mappings":"AACA,SAA2BA,SAAS,EAAsBC,WAAW,QAAQ,OAAM;AAEnF,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,gCAAgC,EAChCC,yBAAyB,EACzBC,yBAAyB,EACzBC,2BAA2B,QACtB,4BAA2B;AAClC,SAASC,aAAa,EAAEC,YAAY,QAAQ,gCAA+B;AAG3E,SAASC,SAAS,EAAEC,KAAK,QAAQ,oCAAmC;AACpE,SAASC,YAAY,QAAQ,oBAAm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AAS,IAAI,CAACA,OAAO;YACrByD,KAAKD;YACLa,cAAc;YACdC,MAAM;gBAAC5C,QAAQT,WAAW;gBAAES,QAAQR,aAAa;gBAAEd;gBAAOe;aAAM;QAClE;IACF;IAEA;;;;GAIC,GACD,MAAaoD,0BAA0BtD,WAAwB,EAAoB;QACjF,OAAO,MAAM,IAAI,CAACZ,QAAQ,CAACC,IAAI,CAACiE,yBAAyB,CAAC;YACxDtD,YAAYkB,OAAO;YACnBlB,YAAYoC,SAAS;SACtB;IACH;IAEA;;;;;;;GAOC,GACD,MAAaD,kCACXnC,WAAwB,EACxBC,aAA4B,EACG;QAC/B,MAAMsD,SAAS,MAAM,IAAI,CAACnE,QAAQ,CAACC,IAAI,CAAC8C,iCAAiC,CAAC;YACxEnC;YACAC;SACD;QACD,OAAOsD;IACT;IAEA;;;;;;GAMC,GACD,MAAaC,8BACXxD,WAAwB,EACxBC,aAA4B,EACG;QAC/B,MAAMsD,SAAS,MAAM,IAAI,CAACnE,QAAQ,CAACC,IAAI,CAACmE,6BAA6B,CAAC;YACpExD;YACAC;SACD;QACD,OAAOsD;IACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractBase.d.ts","sourceRoot":"","sources":["../../src/contracts/ContractBase.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,GAAG,EACH,OAAO,EACP,OAAO,EAQP,kBAAkB,EACnB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE7E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAKxD,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,GAAG,CAAA;IACR,YAAY,EAAE,MAAM,CAAA;IACpB,IA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