@boostxyz/sdk 1.1.0-alpha.23 → 2.0.0-alpha.25
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/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.js +7 -7
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +32 -5
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +164 -137
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +10 -10
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.js +10 -10
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore.cjs +2 -1
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +564 -1
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +1322 -29
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.js +27 -27
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.js +23 -23
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +23 -23
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.js +8 -8
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.js +12 -12
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.js +16 -16
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +2 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +42 -15
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js +188 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.cjs +2 -0
- package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +7 -5
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/{Incentive-rM5nKznp.js → Incentives/ERC20VariableIncentive.js} +42 -67
- package/dist/Incentives/ERC20VariableIncentive.js.map +1 -0
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.d.ts +552 -3
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +40 -16
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.js +8 -8
- package/dist/{SimpleDenyList-DNj5qDWM.cjs → SimpleDenyList-BdlpZdDz.cjs} +2 -2
- package/dist/{SimpleDenyList-DNj5qDWM.cjs.map → SimpleDenyList-BdlpZdDz.cjs.map} +1 -1
- package/dist/{SimpleDenyList-BDXpY74P.js → SimpleDenyList-D0cyVUVv.js} +16 -16
- package/dist/{SimpleDenyList-BDXpY74P.js.map → SimpleDenyList-D0cyVUVv.js.map} +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs +2 -0
- package/dist/Validators/LimitedSignerValidator.cjs.map +1 -0
- package/dist/Validators/LimitedSignerValidator.d.ts +806 -0
- package/dist/Validators/LimitedSignerValidator.d.ts.map +1 -0
- package/dist/Validators/LimitedSignerValidator.js +299 -0
- package/dist/Validators/LimitedSignerValidator.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +2 -2
- package/dist/Validators/SignerValidator.js +5 -5
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +22 -2
- package/dist/Validators/Validator.d.ts.map +1 -1
- package/dist/Validators/Validator.js +26 -17
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/{componentInterfaces-BBCFkrZv.js → componentInterfaces-bIVo8eyA.js} +9 -9
- package/dist/componentInterfaces-bIVo8eyA.js.map +1 -0
- package/dist/{deployments-fJsWblwS.js → deployments-Ccx1MtoK.js} +5 -5
- package/dist/deployments-Ccx1MtoK.js.map +1 -0
- package/dist/{generated-CsNyWPKA.js → generated-BAKNSOjJ.js} +661 -381
- package/dist/generated-BAKNSOjJ.js.map +1 -0
- package/dist/generated-Cqn4wS01.cjs +3 -0
- package/dist/generated-Cqn4wS01.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +145 -132
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +27 -26
- package/dist/utils.js.map +1 -1
- package/package.json +21 -5
- package/src/Actions/EventAction.test.ts +381 -122
- package/src/Actions/EventAction.ts +85 -23
- package/src/BoostCore.test.ts +3 -3
- package/src/BoostCore.ts +51 -5
- package/src/Incentives/AllowListIncentive.test.ts +19 -21
- package/src/Incentives/CGDAIncentive.test.ts +20 -22
- package/src/Incentives/ERC1155Incentive.test.ts +14 -15
- package/src/Incentives/ERC20Incentive.test.ts +17 -19
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +62 -10
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +79 -37
- package/src/Incentives/ERC20VariableIncentive.test.ts +16 -18
- package/src/Incentives/ERC20VariableIncentive.ts +16 -8
- package/src/Incentives/Incentive.ts +4 -1
- package/src/Incentives/PointsIncentive.test.ts +3 -5
- package/src/Validators/LimitedSignerValidator.test.ts +223 -0
- package/src/Validators/LimitedSignerValidator.ts +707 -0
- package/src/Validators/SignerValidator.test.ts +21 -22
- package/src/Validators/SignerValidator.ts +2 -2
- package/src/Validators/Validator.test.ts +7 -1
- package/src/Validators/Validator.ts +30 -3
- package/src/index.test.ts +2 -0
- package/src/index.ts +1 -0
- package/src/utils.ts +11 -0
- package/dist/BoostCore-Btl5BdAs.cjs +0 -3
- package/dist/BoostCore-Btl5BdAs.cjs.map +0 -1
- package/dist/BoostCore-CD56zbYX.js +0 -2641
- package/dist/BoostCore-CD56zbYX.js.map +0 -1
- package/dist/Incentive-CcnOIc8L.cjs +0 -2
- package/dist/Incentive-CcnOIc8L.cjs.map +0 -1
- package/dist/Incentive-rM5nKznp.js.map +0 -1
- package/dist/componentInterfaces-BBCFkrZv.js.map +0 -1
- package/dist/deployments-fJsWblwS.js.map +0 -1
- package/dist/generated-CsNyWPKA.js.map +0 -1
- package/dist/generated-DHerxf1y.cjs +0 -3
- package/dist/generated-DHerxf1y.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./BoostRegistry.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./BoostRegistry.cjs"),n=require("./BoostCore.cjs"),A=require("./Boost.cjs"),C=require("./Actions/Action.cjs"),a=require("./Actions/EventAction.cjs"),p=require("./AllowLists/AllowList.cjs"),c=require("./AllowLists/SimpleAllowList.cjs"),u=require("./SimpleDenyList-BdlpZdDz.cjs"),g=require("./Budgets/Budget.cjs"),o=require("./Budgets/ManagedBudget.cjs"),B=require("./Deployable/Deployable.cjs"),T=require("./Deployable/Contract.cjs"),V=require("./Deployable/DeployableTarget.cjs"),I=require("./Deployable/DeployableTargetWithRBAC.cjs"),S=require("./Incentives/AllowListIncentive.cjs"),m=require("./Incentives/CGDAIncentive.cjs"),v=require("./Incentives/ERC20Incentive.cjs"),P=require("./Incentives/ERC20VariableIncentive.cjs"),E=require("./Incentives/ERC20VariableCriteriaIncentive.cjs"),b=require("./Incentives/Incentive.cjs"),R=require("./Incentives/PointsIncentive.cjs"),l=require("./Validators/SignerValidator.cjs"),d=require("./Validators/LimitedSignerValidator.cjs"),y=require("./Validators/Validator.cjs"),e=require("./errors.cjs"),i=require("./utils.cjs"),D=require("./claiming.cjs"),t=require("./transfers.cjs"),L=require("./Auth/PassthroughAuth.cjs"),r=require("./generated-Cqn4wS01.cjs");exports.BOOST_REGISTRY_ADDRESS=s.BOOST_REGISTRY_ADDRESS;exports.BOOST_REGISTRY_ADDRESSES=s.BOOST_REGISTRY_ADDRESSES;exports.BoostRegistry=s.BoostRegistry;exports.BOOST_CORE_ADDRESS=n.BOOST_CORE_ADDRESS;exports.BOOST_CORE_ADDRESSES=n.BOOST_CORE_ADDRESSES;exports.BOOST_CORE_CLAIM_FEE=n.BOOST_CORE_CLAIM_FEE;exports.BoostCore=n.BoostCore;exports.Boost=A.Boost;exports.prepareBoostPayload=A.prepareBoostPayload;exports.ActionByComponentInterface=C.ActionByComponentInterface;exports.actionFromAddress=C.actionFromAddress;exports.EventAction=a.EventAction;exports.FilterType=a.FilterType;exports.PrimitiveType=a.PrimitiveType;exports.SignatureType=a.SignatureType;exports.anyActionParameter=a.anyActionParameter;exports.isEventActionPayloadSimple=a.isEventActionPayloadSimple;exports.prepareEventActionPayload=a.prepareEventActionPayload;exports.transactionSenderClaimant=a.transactionSenderClaimant;exports.AllowListByComponentInterface=p.AllowListByComponentInterface;exports.OpenAllowList=p.OpenAllowList;exports.allowListFromAddress=p.allowListFromAddress;exports.LIST_MANAGER_ROLE=c.LIST_MANAGER_ROLE;exports.SimpleAllowList=c.SimpleAllowList;exports.prepareSimpleAllowListPayload=c.prepareSimpleAllowListPayload;exports.SimpleDenyList=u.SimpleDenyList;exports.prepareSimpleDenyListPayload=u.prepareSimpleDenyListPayload;exports.BudgetByComponentInterface=g.BudgetByComponentInterface;exports.budgetFromAddress=g.budgetFromAddress;exports.ManagedBudget=o.ManagedBudget;exports.ManagedBudgetRoles=o.ManagedBudgetRoles;exports.isERC1155TransferPayload=o.isERC1155TransferPayload;exports.isFungibleTransfer=o.isFungibleTransfer;exports.prepareManagedBudgetPayload=o.prepareManagedBudgetPayload;exports.prepareTransfer=o.prepareTransfer;exports.Deployable=B.Deployable;exports.Contract=T.Contract;exports.DeployableTarget=V.DeployableTarget;exports.DeployableTargetWithRBAC=I.DeployableTargetWithRBAC;exports.Roles=I.Roles;exports.AllowListIncentive=S.AllowListIncentive;exports.prepareAllowListIncentivePayload=S.prepareAllowListIncentivePayload;exports.CGDAIncentive=m.CGDAIncentive;exports.prepareCGDAIncentivePayload=m.prepareCGDAIncentivePayload;exports.ERC20Incentive=v.ERC20Incentive;exports.prepareERC20IncentivePayload=v.prepareERC20IncentivePayload;exports.ERC20VariableIncentive=P.ERC20VariableIncentive;exports.prepareERC20VariableIncentivePayload=P.prepareERC20VariableIncentivePayload;exports.ERC20VariableCriteriaIncentive=E.ERC20VariableCriteriaIncentive;exports.gasRebateIncentiveCriteria=E.gasRebateIncentiveCriteria;exports.prepareERC20VariableCriteriaIncentivePayload=E.prepareERC20VariableCriteriaIncentivePayload;exports.IncentiveByComponentInterface=b.IncentiveByComponentInterface;exports.incentiveFromAddress=b.incentiveFromAddress;exports.PointsIncentive=R.PointsIncentive;exports.preparePointsIncentivePayload=R.preparePointsIncentivePayload;exports.SignerValidator=l.SignerValidator;exports.prepareSignerValidatorClaimDataPayload=l.prepareSignerValidatorClaimDataPayload;exports.prepareSignerValidatorInputParams=l.prepareSignerValidatorInputParams;exports.prepareSignerValidatorPayload=l.prepareSignerValidatorPayload;exports.LimitedSignerValidator=d.LimitedSignerValidator;exports.prepareLimitedSignerValidatorClaimDataPayload=d.prepareLimitedSignerValidatorClaimDataPayload;exports.prepareLimitedSignerValidatorInputParams=d.prepareLimitedSignerValidatorInputParams;exports.prepareLimitedSignerValidatorPayload=d.prepareLimitedSignerValidatorPayload;exports.BoostValidatorEOA=y.BoostValidatorEOA;exports.ValidatorByComponentInterface=y.ValidatorByComponentInterface;exports.validatorFromAddress=y.validatorFromAddress;exports.BoostCoreNoIdentifierEmitted=e.BoostCoreNoIdentifierEmitted;exports.BoostNotFoundError=e.BoostNotFoundError;exports.BudgetMustAuthorizeBoostCore=e.BudgetMustAuthorizeBoostCore;exports.ContractAddressRequiredError=e.ContractAddressRequiredError;exports.DecodedArgsError=e.DecodedArgsError;exports.DecodedArgsMalformedError=e.DecodedArgsMalformedError;exports.DeployableAlreadyDeployedError=e.DeployableAlreadyDeployedError;exports.DeployableBuildParametersUnspecifiedError=e.DeployableBuildParametersUnspecifiedError;exports.DeployableMissingPayloadError=e.DeployableMissingPayloadError;exports.DeployableUnknownOwnerProvidedError=e.DeployableUnknownOwnerProvidedError;exports.DeployableWagmiConfigurationRequiredError=e.DeployableWagmiConfigurationRequiredError;exports.FieldActionValidationError=e.FieldActionValidationError;exports.FieldValueNotComparableError=e.FieldValueNotComparableError;exports.FieldValueUndefinedError=e.FieldValueUndefinedError;exports.FunctionDataDecodeError=e.FunctionDataDecodeError;exports.IncentiveCriteriaNotFoundError=e.IncentiveCriteriaNotFoundError;exports.IncentiveNotCloneableError=e.IncentiveNotCloneableError;exports.InvalidComponentInterfaceError=e.InvalidComponentInterfaceError;exports.InvalidCriteriaTypeError=e.InvalidCriteriaTypeError;exports.InvalidNumericalCriteriaError=e.InvalidNumericalCriteriaError;exports.InvalidProtocolChainIdError=e.InvalidProtocolChainIdError;exports.MustInitializeBudgetError=e.MustInitializeBudgetError;exports.NoConnectedChainIdError=e.NoConnectedChainIdError;exports.NoContractAddressUponReceiptError=e.NoContractAddressUponReceiptError;exports.NoEventActionStepsProvidedError=e.NoEventActionStepsProvidedError;exports.NoMatchingLogsError=e.NoMatchingLogsError;exports.TooManyEventActionStepsProvidedError=e.TooManyEventActionStepsProvidedError;exports.UnknownTransferPayloadSupplied=e.UnknownTransferPayloadSupplied;exports.UnparseableAbiParamError=e.UnparseableAbiParamError;exports.UnrecognizedFilterTypeError=e.UnrecognizedFilterTypeError;exports.ValidationAbiMissingError=e.ValidationAbiMissingError;exports.CheatCodes=i.CheatCodes;exports.RegistryType=i.RegistryType;exports.assertValidAddressByChainId=i.assertValidAddressByChainId;exports.awaitResult=i.awaitResult;exports.bytes4=i.bytes4;exports.getDeployedContractAddress=i.getDeployedContractAddress;exports.StrategyType=D.StrategyType;exports.prepareClaimPayload=D.prepareClaimPayload;exports.AssetType=t.AssetType;exports.prepareERC1155Payload=t.prepareERC1155Payload;exports.prepareERC1155Transfer=t.prepareERC1155Transfer;exports.prepareFungiblePayload=t.prepareFungiblePayload;exports.prepareFungibleTransfer=t.prepareFungibleTransfer;exports.prepareTransferPayload=t.prepareTransferPayload;exports.PassthroughAuth=L.PassthroughAuth;exports.allowListIncentiveAbi=r.O;exports.boostCoreAbi=r.T;exports.boostRegistryAbi=r.re;exports.cgdaIncentiveAbi=r.b;exports.erc20IncentiveAbi=r.y;exports.erc20VariableCriteriaIncentiveAbi=r.m;exports.erc20VariableIncentiveAbi=r.f;exports.limitedSignerValidatorAbi=r.E;exports.managedBudgetAbi=r.d;exports.passthroughAuthAbi=r.Se;exports.pointsIncentiveAbi=r.w;exports.rbacAbi=r.R;exports.signerValidatorAbi=r.x;exports.simpleAllowListAbi=r.h;exports.simpleDenyListAbi=r.g;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './Incentives/ERC20VariableCriteriaIncentive';
|
|
|
20
20
|
export * from './Incentives/Incentive';
|
|
21
21
|
export * from './Incentives/PointsIncentive';
|
|
22
22
|
export * from './Validators/SignerValidator';
|
|
23
|
+
export * from './Validators/LimitedSignerValidator';
|
|
23
24
|
export * from './Validators/Validator';
|
|
24
25
|
export * from './errors';
|
|
25
26
|
export * from './utils';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAIxB,cAAc,kBAAkB,CAAC;AAGjC,cAAc,uBAAuB,CAAC;AAItC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAI5C,cAAc,kBAAkB,CAAC;AAGjC,cAAc,yBAAyB,CAAC;AAIxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AAItD,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6CAA6C,CAAC;AAE5D,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAI7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AAIvC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAI5B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAIxB,cAAc,kBAAkB,CAAC;AAGjC,cAAc,uBAAuB,CAAC;AAItC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAI5C,cAAc,kBAAkB,CAAC;AAGjC,cAAc,yBAAyB,CAAC;AAIxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AAItD,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6CAA6C,CAAC;AAE5D,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAI7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AAIvC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAI5B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,147 +1,160 @@
|
|
|
1
1
|
import { BOOST_REGISTRY_ADDRESS as o, BOOST_REGISTRY_ADDRESSES as a, BoostRegistry as t } from "./BoostRegistry.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Boost as
|
|
4
|
-
import { ActionByComponentInterface as
|
|
5
|
-
import { EventAction as
|
|
6
|
-
import { AllowListByComponentInterface as
|
|
7
|
-
import { LIST_MANAGER_ROLE as
|
|
8
|
-
import { S as h, p as
|
|
9
|
-
import { BudgetByComponentInterface as
|
|
10
|
-
import { ManagedBudget as
|
|
11
|
-
import { Deployable as
|
|
12
|
-
import { Contract as
|
|
13
|
-
import { DeployableTarget as
|
|
14
|
-
import { DeployableTargetWithRBAC as
|
|
15
|
-
import { AllowListIncentive as
|
|
16
|
-
import { CGDAIncentive as
|
|
2
|
+
import { BOOST_CORE_ADDRESS as n, BOOST_CORE_ADDRESSES as p, BOOST_CORE_CLAIM_FEE as l, BoostCore as d } from "./BoostCore.js";
|
|
3
|
+
import { Boost as m, prepareBoostPayload as E } from "./Boost.js";
|
|
4
|
+
import { ActionByComponentInterface as y, actionFromAddress as A } from "./Actions/Action.js";
|
|
5
|
+
import { EventAction as f, FilterType as g, PrimitiveType as b, SignatureType as I, anyActionParameter as S, isEventActionPayloadSimple as v, prepareEventActionPayload as P, transactionSenderClaimant as R } from "./Actions/EventAction.js";
|
|
6
|
+
import { AllowListByComponentInterface as x, OpenAllowList as D, allowListFromAddress as B } from "./AllowLists/AllowList.js";
|
|
7
|
+
import { LIST_MANAGER_ROLE as V, SimpleAllowList as L, prepareSimpleAllowListPayload as O } from "./AllowLists/SimpleAllowList.js";
|
|
8
|
+
import { S as h, p as w } from "./SimpleDenyList-D0cyVUVv.js";
|
|
9
|
+
import { BudgetByComponentInterface as M, budgetFromAddress as N } from "./Budgets/Budget.js";
|
|
10
|
+
import { ManagedBudget as G, ManagedBudgetRoles as z, isERC1155TransferPayload as k, isFungibleTransfer as q, prepareManagedBudgetPayload as W, prepareTransfer as Y } from "./Budgets/ManagedBudget.js";
|
|
11
|
+
import { Deployable as H } from "./Deployable/Deployable.js";
|
|
12
|
+
import { Contract as K } from "./Deployable/Contract.js";
|
|
13
|
+
import { DeployableTarget as X } from "./Deployable/DeployableTarget.js";
|
|
14
|
+
import { DeployableTargetWithRBAC as $, Roles as ee } from "./Deployable/DeployableTargetWithRBAC.js";
|
|
15
|
+
import { AllowListIncentive as oe, prepareAllowListIncentivePayload as ae } from "./Incentives/AllowListIncentive.js";
|
|
16
|
+
import { CGDAIncentive as ie, prepareCGDAIncentivePayload as ne } from "./Incentives/CGDAIncentive.js";
|
|
17
17
|
import { ERC20Incentive as le, prepareERC20IncentivePayload as de } from "./Incentives/ERC20Incentive.js";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
18
|
+
import { ERC20VariableIncentive as me, prepareERC20VariableIncentivePayload as Ee } from "./Incentives/ERC20VariableIncentive.js";
|
|
19
|
+
import { ERC20VariableCriteriaIncentive as ye, gasRebateIncentiveCriteria as Ae, prepareERC20VariableCriteriaIncentivePayload as Ce } from "./Incentives/ERC20VariableCriteriaIncentive.js";
|
|
20
|
+
import { IncentiveByComponentInterface as ge, incentiveFromAddress as be } from "./Incentives/Incentive.js";
|
|
21
|
+
import { PointsIncentive as Se, preparePointsIncentivePayload as ve } from "./Incentives/PointsIncentive.js";
|
|
22
|
+
import { SignerValidator as Re, prepareSignerValidatorClaimDataPayload as ue, prepareSignerValidatorInputParams as xe, prepareSignerValidatorPayload as De } from "./Validators/SignerValidator.js";
|
|
23
|
+
import { LimitedSignerValidator as Te, prepareLimitedSignerValidatorClaimDataPayload as Ve, prepareLimitedSignerValidatorInputParams as Le, prepareLimitedSignerValidatorPayload as Oe } from "./Validators/LimitedSignerValidator.js";
|
|
24
|
+
import { BoostValidatorEOA as he, ValidatorByComponentInterface as we, validatorFromAddress as _e } from "./Validators/Validator.js";
|
|
25
|
+
import { BoostCoreNoIdentifierEmitted as Ne, BoostNotFoundError as Ue, BudgetMustAuthorizeBoostCore as Ge, ContractAddressRequiredError as ze, DecodedArgsError as ke, DecodedArgsMalformedError as qe, DeployableAlreadyDeployedError as We, DeployableBuildParametersUnspecifiedError as Ye, DeployableMissingPayloadError as je, DeployableUnknownOwnerProvidedError as He, DeployableWagmiConfigurationRequiredError as Je, FieldActionValidationError as Ke, FieldValueNotComparableError as Qe, FieldValueUndefinedError as Xe, FunctionDataDecodeError as Ze, IncentiveCriteriaNotFoundError as $e, IncentiveNotCloneableError as er, InvalidComponentInterfaceError as rr, InvalidCriteriaTypeError as or, InvalidNumericalCriteriaError as ar, InvalidProtocolChainIdError as tr, MustInitializeBudgetError as ir, NoConnectedChainIdError as nr, NoContractAddressUponReceiptError as pr, NoEventActionStepsProvidedError as lr, NoMatchingLogsError as dr, TooManyEventActionStepsProvidedError as sr, UnknownTransferPayloadSupplied as mr, UnparseableAbiParamError as Er, UnrecognizedFilterTypeError as cr, ValidationAbiMissingError as yr } from "./errors.js";
|
|
26
|
+
import { CheatCodes as Cr, RegistryType as fr, assertValidAddressByChainId as gr, awaitResult as br, bytes4 as Ir, getDeployedContractAddress as Sr } from "./utils.js";
|
|
27
|
+
import { StrategyType as Pr, prepareClaimPayload as Rr } from "./claiming.js";
|
|
28
|
+
import { AssetType as xr, prepareERC1155Payload as Dr, prepareERC1155Transfer as Br, prepareFungiblePayload as Tr, prepareFungibleTransfer as Vr, prepareTransferPayload as Lr } from "./transfers.js";
|
|
29
|
+
import { PassthroughAuth as Fr } from "./Auth/PassthroughAuth.js";
|
|
30
|
+
import { O as wr, T as _r, r as Mr, b as Nr, y as Ur, m as Gr, f as zr, E as kr, d as qr, S as Wr, w as Yr, R as jr, x as Hr, h as Jr, g as Kr } from "./generated-BAKNSOjJ.js";
|
|
28
31
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
y as ActionByComponentInterface,
|
|
33
|
+
x as AllowListByComponentInterface,
|
|
34
|
+
oe as AllowListIncentive,
|
|
35
|
+
xr as AssetType,
|
|
33
36
|
n as BOOST_CORE_ADDRESS,
|
|
34
37
|
p as BOOST_CORE_ADDRESSES,
|
|
35
|
-
|
|
38
|
+
l as BOOST_CORE_CLAIM_FEE,
|
|
36
39
|
o as BOOST_REGISTRY_ADDRESS,
|
|
37
40
|
a as BOOST_REGISTRY_ADDRESSES,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
m as Boost,
|
|
42
|
+
d as BoostCore,
|
|
43
|
+
Ne as BoostCoreNoIdentifierEmitted,
|
|
44
|
+
Ue as BoostNotFoundError,
|
|
42
45
|
t as BoostRegistry,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
he as BoostValidatorEOA,
|
|
47
|
+
M as BudgetByComponentInterface,
|
|
48
|
+
Ge as BudgetMustAuthorizeBoostCore,
|
|
49
|
+
ie as CGDAIncentive,
|
|
50
|
+
Cr as CheatCodes,
|
|
51
|
+
K as Contract,
|
|
52
|
+
ze as ContractAddressRequiredError,
|
|
53
|
+
ke as DecodedArgsError,
|
|
54
|
+
qe as DecodedArgsMalformedError,
|
|
55
|
+
H as Deployable,
|
|
56
|
+
We as DeployableAlreadyDeployedError,
|
|
57
|
+
Ye as DeployableBuildParametersUnspecifiedError,
|
|
58
|
+
je as DeployableMissingPayloadError,
|
|
59
|
+
X as DeployableTarget,
|
|
60
|
+
$ as DeployableTargetWithRBAC,
|
|
61
|
+
He as DeployableUnknownOwnerProvidedError,
|
|
62
|
+
Je as DeployableWagmiConfigurationRequiredError,
|
|
58
63
|
le as ERC20Incentive,
|
|
59
|
-
|
|
64
|
+
ye as ERC20VariableCriteriaIncentive,
|
|
60
65
|
me as ERC20VariableIncentive,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
66
|
+
f as EventAction,
|
|
67
|
+
Ke as FieldActionValidationError,
|
|
68
|
+
Qe as FieldValueNotComparableError,
|
|
69
|
+
Xe as FieldValueUndefinedError,
|
|
70
|
+
g as FilterType,
|
|
71
|
+
Ze as FunctionDataDecodeError,
|
|
72
|
+
ge as IncentiveByComponentInterface,
|
|
73
|
+
$e as IncentiveCriteriaNotFoundError,
|
|
74
|
+
er as IncentiveNotCloneableError,
|
|
75
|
+
rr as InvalidComponentInterfaceError,
|
|
76
|
+
or as InvalidCriteriaTypeError,
|
|
77
|
+
ar as InvalidNumericalCriteriaError,
|
|
78
|
+
tr as InvalidProtocolChainIdError,
|
|
79
|
+
V as LIST_MANAGER_ROLE,
|
|
80
|
+
Te as LimitedSignerValidator,
|
|
81
|
+
G as ManagedBudget,
|
|
82
|
+
z as ManagedBudgetRoles,
|
|
83
|
+
ir as MustInitializeBudgetError,
|
|
84
|
+
nr as NoConnectedChainIdError,
|
|
85
|
+
pr as NoContractAddressUponReceiptError,
|
|
86
|
+
lr as NoEventActionStepsProvidedError,
|
|
87
|
+
dr as NoMatchingLogsError,
|
|
88
|
+
D as OpenAllowList,
|
|
89
|
+
Fr as PassthroughAuth,
|
|
90
|
+
Se as PointsIncentive,
|
|
91
|
+
b as PrimitiveType,
|
|
92
|
+
fr as RegistryType,
|
|
93
|
+
ee as Roles,
|
|
94
|
+
I as SignatureType,
|
|
95
|
+
Re as SignerValidator,
|
|
90
96
|
L as SimpleAllowList,
|
|
91
97
|
h as SimpleDenyList,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
98
|
+
Pr as StrategyType,
|
|
99
|
+
sr as TooManyEventActionStepsProvidedError,
|
|
100
|
+
mr as UnknownTransferPayloadSupplied,
|
|
101
|
+
Er as UnparseableAbiParamError,
|
|
102
|
+
cr as UnrecognizedFilterTypeError,
|
|
103
|
+
yr as ValidationAbiMissingError,
|
|
104
|
+
we as ValidatorByComponentInterface,
|
|
105
|
+
A as actionFromAddress,
|
|
106
|
+
B as allowListFromAddress,
|
|
107
|
+
wr as allowListIncentiveAbi,
|
|
108
|
+
S as anyActionParameter,
|
|
109
|
+
gr as assertValidAddressByChainId,
|
|
110
|
+
br as awaitResult,
|
|
111
|
+
_r as boostCoreAbi,
|
|
112
|
+
Mr as boostRegistryAbi,
|
|
113
|
+
N as budgetFromAddress,
|
|
114
|
+
Ir as bytes4,
|
|
115
|
+
Nr as cgdaIncentiveAbi,
|
|
116
|
+
Ur as erc20IncentiveAbi,
|
|
117
|
+
Gr as erc20VariableCriteriaIncentiveAbi,
|
|
118
|
+
zr as erc20VariableIncentiveAbi,
|
|
119
|
+
Ae as gasRebateIncentiveCriteria,
|
|
120
|
+
Sr as getDeployedContractAddress,
|
|
121
|
+
be as incentiveFromAddress,
|
|
122
|
+
k as isERC1155TransferPayload,
|
|
123
|
+
v as isEventActionPayloadSimple,
|
|
124
|
+
q as isFungibleTransfer,
|
|
125
|
+
kr as limitedSignerValidatorAbi,
|
|
126
|
+
qr as managedBudgetAbi,
|
|
127
|
+
Wr as passthroughAuthAbi,
|
|
128
|
+
Yr as pointsIncentiveAbi,
|
|
129
|
+
ae as prepareAllowListIncentivePayload,
|
|
130
|
+
E as prepareBoostPayload,
|
|
131
|
+
ne as prepareCGDAIncentivePayload,
|
|
132
|
+
Rr as prepareClaimPayload,
|
|
133
|
+
Dr as prepareERC1155Payload,
|
|
134
|
+
Br as prepareERC1155Transfer,
|
|
126
135
|
de as prepareERC20IncentivePayload,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
136
|
+
Ce as prepareERC20VariableCriteriaIncentivePayload,
|
|
137
|
+
Ee as prepareERC20VariableIncentivePayload,
|
|
138
|
+
P as prepareEventActionPayload,
|
|
139
|
+
Tr as prepareFungiblePayload,
|
|
140
|
+
Vr as prepareFungibleTransfer,
|
|
141
|
+
Ve as prepareLimitedSignerValidatorClaimDataPayload,
|
|
142
|
+
Le as prepareLimitedSignerValidatorInputParams,
|
|
143
|
+
Oe as prepareLimitedSignerValidatorPayload,
|
|
144
|
+
W as prepareManagedBudgetPayload,
|
|
145
|
+
ve as preparePointsIncentivePayload,
|
|
146
|
+
ue as prepareSignerValidatorClaimDataPayload,
|
|
147
|
+
xe as prepareSignerValidatorInputParams,
|
|
148
|
+
De as prepareSignerValidatorPayload,
|
|
149
|
+
O as prepareSimpleAllowListPayload,
|
|
150
|
+
w as prepareSimpleDenyListPayload,
|
|
151
|
+
Y as prepareTransfer,
|
|
152
|
+
Lr as prepareTransferPayload,
|
|
153
|
+
jr as rbacAbi,
|
|
154
|
+
Hr as signerValidatorAbi,
|
|
155
|
+
Jr as simpleAllowListAbi,
|
|
156
|
+
Kr as simpleDenyListAbi,
|
|
157
|
+
R as transactionSenderClaimant,
|
|
158
|
+
_e as validatorFromAddress
|
|
146
159
|
};
|
|
147
160
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@wagmi/core"),a=require("viem"),e=require("./errors.cjs");var s=(t=>(t[t.ACTION=0]="ACTION",t[t.ALLOW_LIST=1]="ALLOW_LIST",t[t.BUDGET=2]="BUDGET",t[t.INCENTIVE=3]="INCENTIVE",t[t.VALIDATOR=4]="VALIDATOR",t))(s||{}),u=(t=>(t[t.ANY_ACTION_PARAM=255]="ANY_ACTION_PARAM",t[t.TX_SENDER_CLAIMANT=255]="TX_SENDER_CLAIMANT",t[t.GAS_REBATE_INCENTIVE=255]="GAS_REBATE_INCENTIVE",t))(u||{});function N(t){return a.slice(a.isHex(t)?a.keccak256(t):a.keccak256(a.toHex(t)),0,4)}async function E(t,c,o){const r=await A.waitForTransactionReceipt(t,{...o,hash:await c});if(!r.contractAddress)throw new e.NoContractAddressUponReceiptError(r);return r.contractAddress}async function I(t,c,o){const{hash:r,result:i}=await c;return await A.waitForTransactionReceipt(t,{...o,hash:r}),i}function T(t,c,o){let r;const i=A.getAccount(t);if(o!==void 0?c[o]&&(r=o):i.chainId!==void 0&&c[i.chainId]&&(r=i.chainId),r===void 0){const n=A.getClient(t);n!=null&&n.chain.id&&c[n==null?void 0:n.chain.id]&&(r=n.chain.id)}if(r===void 0&&(r=11155111),!c[r])throw new e.InvalidProtocolChainIdError(r,Object.keys(c).map(Number));return{chainId:r,address:c[r]}}exports.CheatCodes=u;exports.RegistryType=s;exports.assertValidAddressByChainId=T;exports.awaitResult=I;exports.bytes4=N;exports.getDeployedContractAddress=E;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../src/utils.ts"],"sourcesContent":["import {\n type Config,\n type ReadContractParameters,\n type WatchContractEventParameters,\n type WriteContractParameters,\n getAccount,\n getClient,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n Address,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport {\n InvalidProtocolChainIdError,\n NoConnectedChainIdError,\n NoContractAddressUponReceiptError,\n} from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams<\n abi extends Abi = Abi,\n functionName extends ContractFunctionName<abi> = ContractFunctionName<abi>,\n> = Partial<\n Omit<\n WriteContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n ReadContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {Promise<Address>}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.\n *\n * @export\n * @param {Config} config\n * @param {Record<string, Address>} addressByChainId\n * @param {number} desiredChainId\n * @returns {{ chainId: number, address: Address }}\n * @throws {@link InvalidProtocolChainIdError}\n */\nexport function assertValidAddressByChainId(\n config: Config,\n addressByChainId: Record<number, Address>,\n desiredChainId?: number,\n): { chainId: number; address: Address } {\n let chainId: number | undefined = undefined;\n const wagmiAccount = getAccount(config);\n // if manually providing a chain id for some contract operation, try to use it\n if (desiredChainId !== undefined) {\n if (addressByChainId[desiredChainId]) chainId = desiredChainId;\n } else if (wagmiAccount.chainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiAccount.chainId]) chainId = wagmiAccount.chainId;\n }\n // chainId is still undefined, try to get chain id off viem client\n if (chainId === undefined) {\n const client = getClient(config);\n if (client?.chain.id && addressByChainId[client?.chain.id])\n chainId = client.chain.id;\n }\n // if chainId is STILL undefined, use our default addresses\n // TODO: update this when on prod network\n if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);\n if (!addressByChainId[chainId])\n throw new InvalidProtocolChainIdError(\n chainId,\n Object.keys(addressByChainId).map(Number),\n );\n // biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?\n return { chainId, address: addressByChainId[chainId]! };\n}\n"],"names":["RegistryType","bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","assertValidAddressByChainId","addressByChainId","desiredChainId","chainId","wagmiAccount","getAccount","client","getClient","InvalidProtocolChainIdError"],"mappings":"2JAqCY,IAAAA,GAAAA,IACVA,EAAAA,EAAA,OAAS,CAAT,EAAA,SACAA,EAAAA,EAAA,WAAa,CAAb,EAAA,aACAA,EAAAA,EAAA,OAAS,CAAT,EAAA,SACAA,EAAAA,EAAA,UAAY,CAAZ,EAAA,YACAA,EAAAA,EAAA,UAAY,CAAZ,EAAA,YALUA,IAAAA,GAAA,CAAA,CAAA,EA2GL,SAASC,EAAOC,EAAe,CACpC,OAAOC,EAAM,MAAAC,EAAA,MAAMF,CAAK,EAAIG,EAAU,UAAAH,CAAK,EAAIG,EAAA,UAAUC,EAAM,MAAAJ,CAAK,CAAC,EAAG,EAAG,CAAC,CAC9E,CAasB,eAAAK,EACpBC,EACAC,EACAC,EACA,CACM,MAAAC,EAAU,MAAMC,EAAA,0BAA0BJ,EAAQ,CACtD,GAAGE,EACH,KAAM,MAAMD,CAAA,CACb,EACD,GAAI,CAACE,EAAQ,gBACL,MAAA,IAAIE,EAAAA,kCAAkCF,CAAO,EACrD,OAAOA,EAAQ,eACjB,CAsBsB,eAAAG,EACpBN,EACAO,EACAL,EACiB,CACjB,KAAM,CAAE,KAAAD,EAAM,OAAAO,CAAO,EAAI,MAAMD,EAC/B,aAAMH,EAAAA,0BAA0BJ,EAAQ,CACtC,GAAGE,EACH,KAAAD,CAAA,CACD,EACMO,CACT,CAYgB,SAAAC,EACdT,EACAU,EACAC,EACuC,CACvC,IAAIC,EACE,MAAAC,EAAeC,aAAWd,CAAM,EAStC,GAPIW,IAAmB,OACjBD,EAAiBC,CAAc,IAAaC,EAAAD,GACvCE,EAAa,UAAY,QAE9BH,EAAiBG,EAAa,OAAO,MAAaA,EAAa,SAGjED,IAAY,OAAW,CACnB,MAAAG,EAASC,YAAUhB,CAAM,EAC3Be,GAAA,MAAAA,EAAQ,MAAM,IAAML,EAAiBK,GAAA,YAAAA,EAAQ,MAAM,EAAE,IACvDH,EAAUG,EAAO,MAAM,GAC3B,CAII,GADAH,IAAY,SAAqBA,EAAO,UACxC,CAACF,EAAiBE,CAAO,EAC3B,MAAM,IAAIK,EAAA,4BACRL,EACA,OAAO,KAAKF,CAAgB,EAAE,IAAI,MAAM,CAAA,EAG5C,MAAO,CAAE,QAAAE,EAAS,QAASF,EAAiBE,CAAO,CAAG,CACxD"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../src/utils.ts"],"sourcesContent":["import {\n type Config,\n type ReadContractParameters,\n type WatchContractEventParameters,\n type WriteContractParameters,\n getAccount,\n getClient,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n Address,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport {\n InvalidProtocolChainIdError,\n NoConnectedChainIdError,\n NoContractAddressUponReceiptError,\n} from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n\n/**\n * Enum encapsulating all the different cheat codes for criteria modules.\n * @export\n * @enum {number}\n */\nexport enum CheatCodes {\n ANY_ACTION_PARAM = 255,\n TX_SENDER_CLAIMANT = 255,\n GAS_REBATE_INCENTIVE = 255,\n}\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams<\n abi extends Abi = Abi,\n functionName extends ContractFunctionName<abi> = ContractFunctionName<abi>,\n> = Partial<\n Omit<\n WriteContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n ReadContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {Promise<Address>}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.\n *\n * @export\n * @param {Config} config\n * @param {Record<string, Address>} addressByChainId\n * @param {number} desiredChainId\n * @returns {{ chainId: number, address: Address }}\n * @throws {@link InvalidProtocolChainIdError}\n */\nexport function assertValidAddressByChainId(\n config: Config,\n addressByChainId: Record<number, Address>,\n desiredChainId?: number,\n): { chainId: number; address: Address } {\n let chainId: number | undefined = undefined;\n const wagmiAccount = getAccount(config);\n // if manually providing a chain id for some contract operation, try to use it\n if (desiredChainId !== undefined) {\n if (addressByChainId[desiredChainId]) chainId = desiredChainId;\n } else if (wagmiAccount.chainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiAccount.chainId]) chainId = wagmiAccount.chainId;\n }\n // chainId is still undefined, try to get chain id off viem client\n if (chainId === undefined) {\n const client = getClient(config);\n if (client?.chain.id && addressByChainId[client?.chain.id])\n chainId = client.chain.id;\n }\n // if chainId is STILL undefined, use our default addresses\n // TODO: update this when on prod network\n if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);\n if (!addressByChainId[chainId])\n throw new InvalidProtocolChainIdError(\n chainId,\n Object.keys(addressByChainId).map(Number),\n );\n // biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?\n return { chainId, address: addressByChainId[chainId]! };\n}\n"],"names":["RegistryType","CheatCodes","bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","assertValidAddressByChainId","addressByChainId","desiredChainId","chainId","wagmiAccount","getAccount","client","getClient","InvalidProtocolChainIdError"],"mappings":"2JAqCY,IAAAA,GAAAA,IACVA,EAAAA,EAAA,OAAS,CAAT,EAAA,SACAA,EAAAA,EAAA,WAAa,CAAb,EAAA,aACAA,EAAAA,EAAA,OAAS,CAAT,EAAA,SACAA,EAAAA,EAAA,UAAY,CAAZ,EAAA,YACAA,EAAAA,EAAA,UAAY,CAAZ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AIK,EAAA,4BACRL,EACA,OAAO,KAAKF,CAAgB,EAAE,IAAI,MAAM,CAAA,EAG5C,MAAO,CAAE,QAAAE,EAAS,QAASF,EAAiBE,CAAO,CAAG,CACxD"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -15,6 +15,16 @@ export declare enum RegistryType {
|
|
|
15
15
|
INCENTIVE = 3,
|
|
16
16
|
VALIDATOR = 4
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Enum encapsulating all the different cheat codes for criteria modules.
|
|
20
|
+
* @export
|
|
21
|
+
* @enum {number}
|
|
22
|
+
*/
|
|
23
|
+
export declare enum CheatCodes {
|
|
24
|
+
ANY_ACTION_PARAM = 255,
|
|
25
|
+
TX_SENDER_CLAIMANT = 255,
|
|
26
|
+
GAS_REBATE_INCENTIVE = 255
|
|
27
|
+
}
|
|
18
28
|
/**
|
|
19
29
|
* Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.
|
|
20
30
|
* See (writeContract)[https://viem.sh/docs/contract/writeContract]
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAI7B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EACV,GAAG,EACH,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,IAAI,EAEJ,GAAG,EACH,mCAAmC,EACpC,MAAM,MAAM,CAAC;AAQd,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAA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AMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,iBAEnC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EACnB,UAAU,CAAC,EAAE,IAAI,CAAC,mCAAmC,EAAE,MAAM,CAAC,0BAS/D;AAED;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,OAAO,IAAI;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,MAAM,GAAG,OAAO,EAChD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,EACpD,UAAU,CAAC,EAAE,IAAI,CAAC,mCAAmC,EAAE,MAAM,CAAC,GAC7D,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,cAAc,CAAC,EAAE,MAAM,GACtB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA0BvC"}
|
package/dist/utils.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
import { waitForTransactionReceipt as
|
|
2
|
-
import { slice as
|
|
3
|
-
import { NoContractAddressUponReceiptError as
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
return
|
|
1
|
+
import { waitForTransactionReceipt as a, getAccount as N, getClient as E } from "@wagmi/core";
|
|
2
|
+
import { slice as I, isHex as f, keccak256 as i, toHex as u } from "viem";
|
|
3
|
+
import { NoContractAddressUponReceiptError as _, InvalidProtocolChainIdError as T } from "./errors.js";
|
|
4
|
+
var w = /* @__PURE__ */ ((o) => (o[o.ACTION = 0] = "ACTION", o[o.ALLOW_LIST = 1] = "ALLOW_LIST", o[o.BUDGET = 2] = "BUDGET", o[o.INCENTIVE = 3] = "INCENTIVE", o[o.VALIDATOR = 4] = "VALIDATOR", o))(w || {}), m = /* @__PURE__ */ ((o) => (o[o.ANY_ACTION_PARAM = 255] = "ANY_ACTION_PARAM", o[o.TX_SENDER_CLAIMANT = 255] = "TX_SENDER_CLAIMANT", o[o.GAS_REBATE_INCENTIVE = 255] = "GAS_REBATE_INCENTIVE", o))(m || {});
|
|
5
|
+
function l(o) {
|
|
6
|
+
return I(f(o) ? i(o) : i(u(o)), 0, 4);
|
|
7
7
|
}
|
|
8
|
-
async function
|
|
9
|
-
const t = await
|
|
10
|
-
...
|
|
8
|
+
async function D(o, c, r) {
|
|
9
|
+
const t = await a(o, {
|
|
10
|
+
...r,
|
|
11
11
|
hash: await c
|
|
12
12
|
});
|
|
13
13
|
if (!t.contractAddress)
|
|
14
|
-
throw new
|
|
14
|
+
throw new _(t);
|
|
15
15
|
return t.contractAddress;
|
|
16
16
|
}
|
|
17
|
-
async function
|
|
18
|
-
const { hash: t, result:
|
|
19
|
-
return await
|
|
20
|
-
...
|
|
17
|
+
async function V(o, c, r) {
|
|
18
|
+
const { hash: t, result: n } = await c;
|
|
19
|
+
return await a(o, {
|
|
20
|
+
...r,
|
|
21
21
|
hash: t
|
|
22
|
-
}),
|
|
22
|
+
}), n;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function S(o, c, r) {
|
|
25
25
|
let t;
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
26
|
+
const n = N(o);
|
|
27
|
+
if (r !== void 0 ? c[r] && (t = r) : n.chainId !== void 0 && c[n.chainId] && (t = n.chainId), t === void 0) {
|
|
28
|
+
const A = E(o);
|
|
29
|
+
A != null && A.chain.id && c[A == null ? void 0 : A.chain.id] && (t = A.chain.id);
|
|
30
30
|
}
|
|
31
31
|
if (t === void 0 && (t = 11155111), !c[t])
|
|
32
|
-
throw new
|
|
32
|
+
throw new T(
|
|
33
33
|
t,
|
|
34
34
|
Object.keys(c).map(Number)
|
|
35
35
|
);
|
|
36
36
|
return { chainId: t, address: c[t] };
|
|
37
37
|
}
|
|
38
38
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
l as
|
|
39
|
+
m as CheatCodes,
|
|
40
|
+
w as RegistryType,
|
|
41
|
+
S as assertValidAddressByChainId,
|
|
42
|
+
V as awaitResult,
|
|
43
|
+
l as bytes4,
|
|
44
|
+
D as getDeployedContractAddress
|
|
44
45
|
};
|
|
45
46
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import {\n type Config,\n type ReadContractParameters,\n type WatchContractEventParameters,\n type WriteContractParameters,\n getAccount,\n getClient,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n Address,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport {\n InvalidProtocolChainIdError,\n NoConnectedChainIdError,\n NoContractAddressUponReceiptError,\n} from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams<\n abi extends Abi = Abi,\n functionName extends ContractFunctionName<abi> = ContractFunctionName<abi>,\n> = Partial<\n Omit<\n WriteContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n ReadContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {Promise<Address>}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.\n *\n * @export\n * @param {Config} config\n * @param {Record<string, Address>} addressByChainId\n * @param {number} desiredChainId\n * @returns {{ chainId: number, address: Address }}\n * @throws {@link InvalidProtocolChainIdError}\n */\nexport function assertValidAddressByChainId(\n config: Config,\n addressByChainId: Record<number, Address>,\n desiredChainId?: number,\n): { chainId: number; address: Address } {\n let chainId: number | undefined = undefined;\n const wagmiAccount = getAccount(config);\n // if manually providing a chain id for some contract operation, try to use it\n if (desiredChainId !== undefined) {\n if (addressByChainId[desiredChainId]) chainId = desiredChainId;\n } else if (wagmiAccount.chainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiAccount.chainId]) chainId = wagmiAccount.chainId;\n }\n // chainId is still undefined, try to get chain id off viem client\n if (chainId === undefined) {\n const client = getClient(config);\n if (client?.chain.id && addressByChainId[client?.chain.id])\n chainId = client.chain.id;\n }\n // if chainId is STILL undefined, use our default addresses\n // TODO: update this when on prod network\n if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);\n if (!addressByChainId[chainId])\n throw new InvalidProtocolChainIdError(\n chainId,\n Object.keys(addressByChainId).map(Number),\n );\n // biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?\n return { chainId, address: addressByChainId[chainId]! };\n}\n"],"names":["RegistryType","bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","assertValidAddressByChainId","addressByChainId","desiredChainId","chainId","wagmiAccount","getAccount","client","getClient","InvalidProtocolChainIdError"],"mappings":";;;AAqCY,IAAAA,sBAAAA,OACVA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,aAAa,CAAb,IAAA,cACAA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aALUA,IAAAA,KAAA,CAAA,CAAA;AA2GL,SAASC,EAAOC,GAAe;AACpC,SAAOC,EAAMC,EAAMF,CAAK,IAAIG,EAAUH,CAAK,IAAIG,EAAUC,EAAMJ,CAAK,CAAC,GAAG,GAAG,CAAC;AAC9E;AAasB,eAAAK,EACpBC,GACAC,GACAC,GACA;AACM,QAAAC,IAAU,MAAMC,EAA0BJ,GAAQ;AAAA,IACtD,GAAGE;AAAA,IACH,MAAM,MAAMD;AAAA,EAAA,CACb;AACD,MAAI,CAACE,EAAQ;AACL,UAAA,IAAIE,EAAkCF,CAAO;AACrD,SAAOA,EAAQ;AACjB;AAsBsB,eAAAG,EACpBN,GACAO,GACAL,GACiB;AACjB,QAAM,EAAE,MAAAD,GAAM,QAAAO,EAAO,IAAI,MAAMD;AAC/B,eAAMH,EAA0BJ,GAAQ;AAAA,IACtC,GAAGE;AAAA,IACH,MAAAD;AAAA,EAAA,CACD,GACMO;AACT;AAYgB,SAAAC,EACdT,GACAU,GACAC,GACuC;AACvC,MAAIC;AACE,QAAAC,IAAeC,EAAWd,CAAM;AAStC,MAPIW,MAAmB,SACjBD,EAAiBC,CAAc,MAAaC,IAAAD,KACvCE,EAAa,YAAY,UAE9BH,EAAiBG,EAAa,OAAO,UAAaA,EAAa,UAGjED,MAAY,QAAW;AACnB,UAAAG,IAASC,EAAUhB,CAAM;AAC/B,IAAIe,KAAA,QAAAA,EAAQ,MAAM,MAAML,EAAiBK,KAAA,gBAAAA,EAAQ,MAAM,EAAE,MACvDH,IAAUG,EAAO,MAAM;AAAA,EAC3B;AAII,MADAH,MAAY,WAAqBA,IAAO,WACxC,CAACF,EAAiBE,CAAO;AAC3B,UAAM,IAAIK;AAAA,MACRL;AAAA,MACA,OAAO,KAAKF,CAAgB,EAAE,IAAI,MAAM;AAAA,IAAA;AAG5C,SAAO,EAAE,SAAAE,GAAS,SAASF,EAAiBE,CAAO,EAAG;AACxD;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import {\n type Config,\n type ReadContractParameters,\n type WatchContractEventParameters,\n type WriteContractParameters,\n getAccount,\n getClient,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n Address,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport {\n InvalidProtocolChainIdError,\n NoConnectedChainIdError,\n NoContractAddressUponReceiptError,\n} from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n\n/**\n * Enum encapsulating all the different cheat codes for criteria modules.\n * @export\n * @enum {number}\n */\nexport enum CheatCodes {\n ANY_ACTION_PARAM = 255,\n TX_SENDER_CLAIMANT = 255,\n GAS_REBATE_INCENTIVE = 255,\n}\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams<\n abi extends Abi = Abi,\n functionName extends ContractFunctionName<abi> = ContractFunctionName<abi>,\n> = Partial<\n Omit<\n WriteContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n ReadContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {Promise<Address>}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.\n *\n * @export\n * @param {Config} config\n * @param {Record<string, Address>} addressByChainId\n * @param {number} desiredChainId\n * @returns {{ chainId: number, address: Address }}\n * @throws {@link InvalidProtocolChainIdError}\n */\nexport function assertValidAddressByChainId(\n config: Config,\n addressByChainId: Record<number, Address>,\n desiredChainId?: number,\n): { chainId: number; address: Address } {\n let chainId: number | undefined = undefined;\n const wagmiAccount = getAccount(config);\n // if manually providing a chain id for some contract operation, try to use it\n if (desiredChainId !== undefined) {\n if (addressByChainId[desiredChainId]) chainId = desiredChainId;\n } else if (wagmiAccount.chainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiAccount.chainId]) chainId = wagmiAccount.chainId;\n }\n // chainId is still undefined, try to get chain id off viem client\n if (chainId === undefined) {\n const client = getClient(config);\n if (client?.chain.id && addressByChainId[client?.chain.id])\n chainId = client.chain.id;\n }\n // if chainId is STILL undefined, use our default addresses\n // TODO: update this when on prod network\n if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);\n if (!addressByChainId[chainId])\n throw new InvalidProtocolChainIdError(\n chainId,\n Object.keys(addressByChainId).map(Number),\n );\n // biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?\n return { chainId, address: addressByChainId[chainId]! };\n}\n"],"names":["RegistryType","CheatCodes","bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","assertValidAddressByChainId","addressByChainId","desiredChainId","chainId","wagmiAccount","getAccount","client","getClient","InvalidProtocolChainIdError"],"mappings":";;;AAqCY,IAAAA,sBAAAA,OACVA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,aAAa,CAAb,IAAA,cACAA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aALUA,IAAAA,KAAA,CAAA,CAAA,GAaAC,sBAAAA,OACVA,EAAAA,EAAA,mBAAmB,GAAnB,IAAA,oBACAA,EAAAA,EAAA,qBAAqB,GAArB,IAAA,sBACAA,EAAAA,EAAA,uBAAuB,GAAvB,IAAA,wBAHUA,IAAAA,KAAA,CAAA,CAAA;AAyGL,SAASC,EAAOC,GAAe;AACpC,SAAOC,EAAMC,EAAMF,CAAK,IAAIG,EAAUH,CAAK,IAAIG,EAAUC,EAAMJ,CAAK,CAAC,GAAG,GAAG,CAAC;AAC9E;AAasB,eAAAK,EACpBC,GACAC,GACAC,GACA;AACM,QAAAC,IAAU,MAAMC,EAA0BJ,GAAQ;AAAA,IACtD,GAAGE;AAAA,IACH,MAAM,MAAMD;AAAA,EAAA,CACb;AACD,MAAI,CAACE,EAAQ;AACL,UAAA,IAAIE,EAAkCF,CAAO;AACrD,SAAOA,EAAQ;AACjB;AAsBsB,eAAAG,EACpBN,GACAO,GACAL,GACiB;AACjB,QAAM,EAAE,MAAAD,GAAM,QAAAO,EAAO,IAAI,MAAMD;AAC/B,eAAMH,EAA0BJ,GAAQ;AAAA,IACtC,GAAGE;AAAA,IACH,MAAAD;AAAA,EAAA,CACD,GAC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