@strimz/shared-config 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/index.cjs +67 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +60 -45
- package/dist/index.js.map +1 -1
- package/dist/tiers.cjs +93 -47
- package/dist/tiers.cjs.map +1 -1
- package/dist/tiers.d.cts +22 -21
- package/dist/tiers.d.ts +22 -21
- package/dist/tiers.js +86 -45
- package/dist/tiers.js.map +1 -1
- package/package.json +1 -1
- package/src/tiers.ts +81 -53
package/README.md
CHANGED
|
@@ -25,10 +25,11 @@ pnpm add @strimz/shared-config
|
|
|
25
25
|
## Quick start
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
|
-
import { arcTestnet, getTokenAddress,
|
|
28
|
+
import { arcTestnet, getTokenAddress, planFeeBps, planForVolume } from '@strimz/shared-config'
|
|
29
29
|
|
|
30
30
|
const usdcOnTestnet = getTokenAddress('testnet', 'USDC')
|
|
31
|
-
const
|
|
31
|
+
const starterFeeBps = planFeeBps('starter') // 50 bps
|
|
32
|
+
const plan = planForVolume({ USDC: 1_000_000_000n, EURC: 0n }) // 'starter'
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
## Modules
|
|
@@ -39,7 +40,7 @@ Every group is also available as a subpath import for tree-shaking.
|
|
|
39
40
|
| -------------------------------- | ------------------------------------------------------------------------------------- |
|
|
40
41
|
| `@strimz/shared-config/chains` | `arcTestnet`, `arcMainnet`, `getArcChain`, `isArcChain`, chain id constants |
|
|
41
42
|
| `@strimz/shared-config/tokens` | `TOKENS`, `TOKEN_ADDRESSES`, `getTokenAddress`, `isPaymentToken`, `PaymentToken` type |
|
|
42
|
-
| `@strimz/shared-config/tiers` | `
|
|
43
|
+
| `@strimz/shared-config/tiers` | `PLANS`, `planFeeBps`, `planForVolume`, `planIncludes`, `MerchantTier` type |
|
|
43
44
|
| `@strimz/shared-config/webhooks` | `WEBHOOK_EVENTS`, retry schedule, signature header constants |
|
|
44
45
|
| `@strimz/shared-config/api-keys` | `API_KEY_PREFIXES`, `prefixFor`, `modeFromKey`, `kindFromKey` |
|
|
45
46
|
| `@strimz/shared-config/agents` | `AGENT_CAPABILITIES`, `AGENT_DEFAULTS`, capability metadata |
|
package/dist/index.cjs
CHANGED
|
@@ -142,68 +142,83 @@ function chainIdFor(env) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// src/tiers.ts
|
|
145
|
-
var
|
|
145
|
+
var PAID_FEATURES = [
|
|
146
|
+
"storefront",
|
|
147
|
+
"anomaly_alerts",
|
|
148
|
+
"yield_recommendations"
|
|
149
|
+
];
|
|
150
|
+
var PLANS = {
|
|
146
151
|
free: {
|
|
147
152
|
id: "free",
|
|
148
153
|
name: "Free",
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
subscriptionPremiumBps: 20,
|
|
153
|
-
// +0.2% on recurring => 1.7% effective
|
|
154
|
-
monthlyVolumeCapUsdCents: 1e6,
|
|
155
|
-
// $10,000
|
|
156
|
-
whiteLabelEligible: false,
|
|
154
|
+
feeBps: 0,
|
|
155
|
+
entersAtVolume: 0,
|
|
156
|
+
features: [],
|
|
157
157
|
prioritySupport: false
|
|
158
158
|
},
|
|
159
|
+
starter: {
|
|
160
|
+
id: "starter",
|
|
161
|
+
name: "Starter",
|
|
162
|
+
feeBps: 50,
|
|
163
|
+
entersAtVolume: 1e3,
|
|
164
|
+
features: PAID_FEATURES,
|
|
165
|
+
prioritySupport: true
|
|
166
|
+
},
|
|
159
167
|
growth: {
|
|
160
168
|
id: "growth",
|
|
161
169
|
name: "Growth",
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// 0.8%
|
|
166
|
-
subscriptionPremiumBps: 20,
|
|
167
|
-
// 1.0% effective
|
|
168
|
-
monthlyVolumeCapUsdCents: 1e7,
|
|
169
|
-
// $100,000
|
|
170
|
-
whiteLabelEligible: true,
|
|
171
|
-
prioritySupport: false
|
|
172
|
-
},
|
|
173
|
-
business: {
|
|
174
|
-
id: "business",
|
|
175
|
-
name: "Business",
|
|
176
|
-
monthlyFeeUsdCents: 19900,
|
|
177
|
-
// $199
|
|
178
|
-
oneShotFeeBps: 50,
|
|
179
|
-
// 0.5%
|
|
180
|
-
subscriptionPremiumBps: 20,
|
|
181
|
-
// 0.7% effective
|
|
182
|
-
monthlyVolumeCapUsdCents: 1e8,
|
|
183
|
-
// $1,000,000
|
|
184
|
-
whiteLabelEligible: true,
|
|
170
|
+
feeBps: 40,
|
|
171
|
+
entersAtVolume: 5e4,
|
|
172
|
+
features: PAID_FEATURES,
|
|
185
173
|
prioritySupport: true
|
|
186
174
|
},
|
|
187
175
|
enterprise: {
|
|
188
176
|
id: "enterprise",
|
|
189
177
|
name: "Enterprise",
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
monthlyVolumeCapUsdCents: null,
|
|
194
|
-
whiteLabelEligible: true,
|
|
178
|
+
feeBps: null,
|
|
179
|
+
entersAtVolume: null,
|
|
180
|
+
features: PAID_FEATURES,
|
|
195
181
|
prioritySupport: true
|
|
196
182
|
}
|
|
197
183
|
};
|
|
198
184
|
var DEFAULT_TIER = "free";
|
|
199
|
-
|
|
200
|
-
|
|
185
|
+
var PLAN_ORDER = ["free", "starter", "growth", "enterprise"];
|
|
186
|
+
var VOLUME_PLANS = ["free", "starter", "growth"];
|
|
187
|
+
var PLAN_FEE_CEILING_BPS = Math.max(
|
|
188
|
+
...VOLUME_PLANS.map((plan) => PLANS[plan].feeBps ?? 0)
|
|
189
|
+
);
|
|
190
|
+
function planFeeBps(plan) {
|
|
191
|
+
return PLANS[plan].feeBps;
|
|
192
|
+
}
|
|
193
|
+
function planIncludes(plan, feature) {
|
|
194
|
+
return PLANS[plan].features.includes(feature);
|
|
195
|
+
}
|
|
196
|
+
function plansWith(feature) {
|
|
197
|
+
return PLAN_ORDER.filter((plan) => planIncludes(plan, feature));
|
|
198
|
+
}
|
|
199
|
+
function lowestPlanWith(feature) {
|
|
200
|
+
const plan = PLAN_ORDER.find((candidate) => planIncludes(candidate, feature));
|
|
201
|
+
if (!plan) throw new Error(`no plan includes ${feature}`);
|
|
202
|
+
return plan;
|
|
203
|
+
}
|
|
204
|
+
function thresholdInBaseUnits(plan, token) {
|
|
205
|
+
const wholeUnits = PLANS[plan].entersAtVolume;
|
|
206
|
+
if (wholeUnits === null) throw new Error(`${plan} has no volume threshold`);
|
|
207
|
+
return BigInt(wholeUnits) * 10n ** BigInt(TOKENS[token].decimals);
|
|
208
|
+
}
|
|
209
|
+
function planForVolume(volumes) {
|
|
210
|
+
let reached = "free";
|
|
211
|
+
for (const plan of VOLUME_PLANS) {
|
|
212
|
+
if (PAYMENT_TOKENS.some((token) => volumes[token] >= thresholdInBaseUnits(plan, token))) {
|
|
213
|
+
reached = plan;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return reached;
|
|
201
217
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0);
|
|
218
|
+
function planUpgradeFor(current, volumes) {
|
|
219
|
+
if (current === "enterprise") return null;
|
|
220
|
+
const earned = planForVolume(volumes);
|
|
221
|
+
return PLAN_ORDER.indexOf(earned) > PLAN_ORDER.indexOf(current) ? earned : null;
|
|
207
222
|
}
|
|
208
223
|
|
|
209
224
|
// src/webhooks.ts
|
|
@@ -418,8 +433,9 @@ exports.CCTP_DOMAIN_IDS = CCTP_DOMAIN_IDS;
|
|
|
418
433
|
exports.CCTP_SUPPORTED_SOURCE_CHAINS = CCTP_SUPPORTED_SOURCE_CHAINS;
|
|
419
434
|
exports.DEFAULT_TIER = DEFAULT_TIER;
|
|
420
435
|
exports.PAYMENT_TOKENS = PAYMENT_TOKENS;
|
|
436
|
+
exports.PLANS = PLANS;
|
|
437
|
+
exports.PLAN_FEE_CEILING_BPS = PLAN_FEE_CEILING_BPS;
|
|
421
438
|
exports.RECOVERY_GRACE_PERIODS = RECOVERY_GRACE_PERIODS;
|
|
422
|
-
exports.TIERS = TIERS;
|
|
423
439
|
exports.TOKENS = TOKENS;
|
|
424
440
|
exports.TOKEN_ADDRESSES = TOKEN_ADDRESSES;
|
|
425
441
|
exports.WEBHOOK_DELIVERY_ID_HEADER = WEBHOOK_DELIVERY_ID_HEADER;
|
|
@@ -435,19 +451,23 @@ exports.arcModeFor = arcModeFor;
|
|
|
435
451
|
exports.arcTestnet = arcTestnet;
|
|
436
452
|
exports.assertArcChainId = assertArcChainId;
|
|
437
453
|
exports.chainIdFor = chainIdFor;
|
|
438
|
-
exports.effectiveFeeBps = effectiveFeeBps;
|
|
439
454
|
exports.getArcChain = getArcChain;
|
|
440
455
|
exports.getArcExplorerUrl = getArcExplorerUrl;
|
|
441
456
|
exports.getCctpContracts = getCctpContracts;
|
|
442
|
-
exports.getTier = getTier;
|
|
443
457
|
exports.getTokenAddress = getTokenAddress;
|
|
444
458
|
exports.getTokenBySymbol = getTokenBySymbol;
|
|
445
459
|
exports.isArcChain = isArcChain;
|
|
446
460
|
exports.isArcEnvironment = isArcEnvironment;
|
|
447
461
|
exports.isPaymentToken = isPaymentToken;
|
|
448
462
|
exports.kindFromKey = kindFromKey;
|
|
463
|
+
exports.lowestPlanWith = lowestPlanWith;
|
|
449
464
|
exports.modeFromKey = modeFromKey;
|
|
450
465
|
exports.parseArcEnvironment = parseArcEnvironment;
|
|
466
|
+
exports.planFeeBps = planFeeBps;
|
|
467
|
+
exports.planForVolume = planForVolume;
|
|
468
|
+
exports.planIncludes = planIncludes;
|
|
469
|
+
exports.planUpgradeFor = planUpgradeFor;
|
|
470
|
+
exports.plansWith = plansWith;
|
|
451
471
|
exports.prefixFor = prefixFor;
|
|
452
472
|
//# sourceMappingURL=index.cjs.map
|
|
453
473
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chains.ts","../src/tokens.ts","../src/tiers.ts","../src/webhooks.ts","../src/api-keys.ts","../src/agents.ts","../src/cctp.ts"],"names":["defineChain"],"mappings":";;;;;AAaO,IAAM,oBAAA,GAAuB;AAC7B,IAAM,oBAAA,GAAuB;AAEpC,IAAM,WAAA,GAAc;AAAA,EAClB,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,MAAA;AAAA,EACR,QAAA,EAAU;AACZ,CAAA;AAEO,IAAM,aAAoBA,gBAAA,CAAY;AAAA,EAC3C,EAAA,EAAI,oBAAA;AAAA,EACJ,IAAA,EAAM,aAAA;AAAA,EACN,cAAA,EAAgB,WAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,EAAE,IAAA,EAAM,CAAC,4BAA4B,CAAA,EAAE;AAAA,IAChD,MAAA,EAAQ,EAAE,IAAA,EAAM,CAAC,4BAA4B,CAAA;AAAE,GACjD;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,sBAAA;AAAA,MACN,GAAA,EAAK;AAAA;AACP,GACF;AAAA,EACA,OAAA,EAAS;AACX,CAAC;AAEM,IAAM,aAAoBA,gBAAA,CAAY;AAAA,EAC3C,EAAA,EAAI,oBAAA;AAAA,EACJ,IAAA,EAAM,KAAA;AAAA,EACN,cAAA,EAAgB,WAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,EAAE,IAAA,EAAM,CAAC,4BAA4B,CAAA,EAAE;AAAA,IAChD,MAAA,EAAQ,EAAE,IAAA,EAAM,CAAC,4BAA4B,CAAA;AAAE,GACjD;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,cAAA;AAAA,MACN,GAAA,EAAK;AAAA;AACP,GACF;AAAA,EACA,OAAA,EAAS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,cAAA,GAA0D;AAAA,EACrE,OAAA,EAAS;AAAA,IACP,gBAAA,EAAkB,4CAAA;AAAA,IAClB,oBAAA,EAAsB,4CAAA;AAAA,IACtB,aAAA,EAAe,4CAAA;AAAA,IACf,aAAA,EAAe,4CAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,OAAA,EAAS;AAAA;AAAA;AAAA,IAGP,gBAAA,EAAkB,4CAAA;AAAA,IAClB,oBAAA,EAAsB,4CAAA;AAAA,IACtB,aAAA,EAAe,4CAAA;AAAA,IACf,aAAA,EAAe,4CAAA;AAAA,IACf,QAAA,EAAU;AAAA;AAEd;AAGO,IAAM,eAAA,GAAkB;AAAA,EAC7B,QAAA,EAAU,CAAA;AAAA,EACV,SAAA,EAAW,CAAA;AAAA,EACX,QAAA,EAAU,CAAA;AAAA,EACV,QAAA,EAAU,CAAA;AAAA,EACV,KAAA,EAAO,CAAA;AAAA,EACP,MAAA,EAAQ,CAAA;AAAA,EACR,IAAA,EAAM,CAAA;AAAA,EACN,OAAA,EAAS,CAAA;AAAA,EACT,GAAA,EAAK;AACP;AAIO,IAAM,4BAAA,GAA2D;AAAA,EACtE,UAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF;AAEO,SAAS,iBAAiB,GAAA,EAAsC;AACrE,EAAA,OAAO,cAAA,CAAe,mBAAA,CAAoB,GAAG,CAAC,CAAA;AAChD","file":"index.cjs","sourcesContent":["/**\n * Arc blockchain definitions.\n *\n * Arc is Circle's stablecoin-native L1 where gas is paid in USDC.\n * - Testnet is live (chain id 5042002).\n * - Mainnet beta is expected in 2026; the mainnet entry is a placeholder\n * until Circle publishes the production chain id and RPC endpoint.\n *\n * @see https://docs.arc.network\n */\n\nimport { defineChain, type Chain } from 'viem'\n\nexport const ARC_TESTNET_CHAIN_ID = 5042002 as const\nexport const ARC_MAINNET_CHAIN_ID = 5042 as const\n\nconst NATIVE_USDC = {\n name: 'USDC',\n symbol: 'USDC',\n decimals: 18,\n} as const\n\nexport const arcTestnet: Chain = defineChain({\n id: ARC_TESTNET_CHAIN_ID,\n name: 'Arc Testnet',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.testnet.arc.io'] },\n public: { http: ['https://rpc.testnet.arc.io'] },\n },\n blockExplorers: {\n default: {\n name: 'Arc Testnet Explorer',\n url: 'https://explorer.testnet.arc.io',\n },\n },\n testnet: true,\n})\n\nexport const arcMainnet: Chain = defineChain({\n id: ARC_MAINNET_CHAIN_ID,\n name: 'Arc',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.mainnet.arc.io'] },\n public: { http: ['https://rpc.mainnet.arc.io'] },\n },\n blockExplorers: {\n default: {\n name: 'Arc Explorer',\n url: 'https://explorer.arc.io',\n },\n },\n testnet: false,\n})\n\nexport type ArcEnvironment = 'testnet' | 'mainnet'\n\nexport const ARC_CHAINS: Record<ArcEnvironment, Chain> = {\n testnet: arcTestnet,\n mainnet: arcMainnet,\n}\n\nexport const ARC_ENVIRONMENTS: readonly ArcEnvironment[] = ['testnet', 'mainnet'] as const\n\nexport function isArcEnvironment(value: unknown): value is ArcEnvironment {\n return typeof value === 'string' && (ARC_ENVIRONMENTS as readonly string[]).includes(value)\n}\n\nexport function parseArcEnvironment(value: unknown): ArcEnvironment {\n if (isArcEnvironment(value)) return value\n throw new Error(\n `unknown Arc environment ${JSON.stringify(value)}: expected one of ${ARC_ENVIRONMENTS.join(', ')}`,\n )\n}\n\nexport function getArcChain(env: ArcEnvironment): Chain {\n return ARC_CHAINS[parseArcEnvironment(env)]\n}\n\nexport function getArcExplorerUrl(env: ArcEnvironment): string {\n const explorer = getArcChain(env).blockExplorers?.default.url\n if (!explorer) throw new Error(`Arc ${env} has no block explorer configured`)\n return explorer\n}\n\nexport function arcExplorerTxUrl(env: ArcEnvironment, txHash: string): string {\n return `${getArcExplorerUrl(env)}/tx/${txHash}`\n}\n\nexport function arcEnvironmentForChainId(chainId: number): ArcEnvironment {\n const env = ARC_ENVIRONMENTS.find((candidate) => ARC_CHAINS[candidate].id === chainId)\n if (!env) {\n throw new Error(\n `chain id ${chainId} is not an Arc chain: expected ${ARC_TESTNET_CHAIN_ID} (testnet) or ${ARC_MAINNET_CHAIN_ID} (mainnet)`,\n )\n }\n return env\n}\n\nexport function assertArcChainId(env: ArcEnvironment, rpcChainId: number): void {\n const expected = getArcChain(env).id\n if (rpcChainId !== expected) {\n throw new Error(\n `ARC_RPC_URL serves chain id ${rpcChainId}, but ARC_ENVIRONMENT=${env} expects chain id ${expected}`,\n )\n }\n}\n\nexport function isArcChain(chainId: number): boolean {\n return chainId === ARC_TESTNET_CHAIN_ID || chainId === ARC_MAINNET_CHAIN_ID\n}\n","/**\n * Token registry for Arc.\n *\n * USDC and EURC are first-class payment tokens. They can be requested in a\n * payment session and used as a subscription currency.\n *\n * USYC is yield-bearing and is treated as a treasury asset only. Merchants\n * can hold it and earn yield, but a payer cannot pay in USYC.\n */\n\nimport type { Address } from 'viem'\nimport { getArcChain, parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport type TokenSymbol = 'USDC' | 'EURC' | 'USYC'\n\n/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */\nexport type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>\n\nexport const PAYMENT_TOKENS: readonly PaymentToken[] = ['USDC', 'EURC'] as const\n\nexport interface TokenDescriptor {\n symbol: TokenSymbol\n name: string\n decimals: number\n /** Whether the token is accepted as direct payment. */\n paymentEligible: boolean\n /** Whether the token is yield-bearing. */\n yieldBearing: boolean\n}\n\nexport interface TokenAddress {\n symbol: TokenSymbol\n address: Address\n chainId: number\n}\n\nexport const TOKENS: Record<TokenSymbol, TokenDescriptor> = {\n USDC: {\n symbol: 'USDC',\n name: 'USD Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n EURC: {\n symbol: 'EURC',\n name: 'Euro Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n USYC: {\n symbol: 'USYC',\n name: 'US Yield Coin',\n decimals: 6,\n paymentEligible: false,\n yieldBearing: true,\n },\n}\n\n/**\n * Native, Circle-issued addresses on Arc.\n * The same address is reused across testnet and mainnet for native tokens\n * since Arc preserves canonical addresses across environments where possible.\n */\nexport const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>> = {\n testnet: {\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n mainnet: {\n // Mainnet addresses pending Arc mainnet beta launch; placeholders mirror\n // testnet for now and must be replaced when Circle publishes the canonical\n // mainnet token registry.\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',\n USYC: '0x8a5D989Bbb96929F689B0200f435f53dA42bF490',\n },\n}\n\nexport function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address {\n return TOKEN_ADDRESSES[parseArcEnvironment(env)][symbol]\n}\n\nexport function getTokenBySymbol(symbol: string): TokenDescriptor | undefined {\n return (TOKENS as Record<string, TokenDescriptor>)[symbol]\n}\n\nexport function isPaymentToken(symbol: string): symbol is PaymentToken {\n return PAYMENT_TOKENS.includes(symbol as PaymentToken)\n}\n\nexport function chainIdFor(env: ArcEnvironment): number {\n return getArcChain(env).id\n}\n","/**\n * Strimz pricing tiers.\n *\n * Fees are expressed in basis points (bps): 100 bps = 1%.\n * The subscription premium is added to the per-transaction rate when the\n * payment is recurring (i.e. originated from a SubscriptionPlan).\n */\n\nexport type MerchantTier = 'free' | 'growth' | 'business' | 'enterprise'\n\nexport interface TierDefinition {\n id: MerchantTier\n name: string\n /** Monthly fee in USD cents (0 for free, null for custom enterprise). */\n monthlyFeeUsdCents: number | null\n /** Per-transaction fee on one-shot payments, in basis points. */\n oneShotFeeBps: number | null\n /** Per-transaction premium added on subscription payments, in basis points. */\n subscriptionPremiumBps: number | null\n /** Monthly transaction volume cap in USD cents. `null` for unlimited. */\n monthlyVolumeCapUsdCents: number | null\n /** Whether the \"Powered by Strimz\" badge can be removed from checkout. */\n whiteLabelEligible: boolean\n /** Whether the tier includes priority support. */\n prioritySupport: boolean\n}\n\nexport const TIERS: Record<MerchantTier, TierDefinition> = {\n free: {\n id: 'free',\n name: 'Free',\n monthlyFeeUsdCents: 0,\n oneShotFeeBps: 150, // 1.5%\n subscriptionPremiumBps: 20, // +0.2% on recurring => 1.7% effective\n monthlyVolumeCapUsdCents: 1_000_000, // $10,000\n whiteLabelEligible: false,\n prioritySupport: false,\n },\n growth: {\n id: 'growth',\n name: 'Growth',\n monthlyFeeUsdCents: 4_900, // $49\n oneShotFeeBps: 80, // 0.8%\n subscriptionPremiumBps: 20, // 1.0% effective\n monthlyVolumeCapUsdCents: 10_000_000, // $100,000\n whiteLabelEligible: true,\n prioritySupport: false,\n },\n business: {\n id: 'business',\n name: 'Business',\n monthlyFeeUsdCents: 19_900, // $199\n oneShotFeeBps: 50, // 0.5%\n subscriptionPremiumBps: 20, // 0.7% effective\n monthlyVolumeCapUsdCents: 100_000_000, // $1,000,000\n whiteLabelEligible: true,\n prioritySupport: true,\n },\n enterprise: {\n id: 'enterprise',\n name: 'Enterprise',\n monthlyFeeUsdCents: null,\n oneShotFeeBps: null,\n subscriptionPremiumBps: null,\n monthlyVolumeCapUsdCents: null,\n whiteLabelEligible: true,\n prioritySupport: true,\n },\n}\n\nexport const DEFAULT_TIER: MerchantTier = 'free'\n\nexport function getTier(id: MerchantTier): TierDefinition {\n return TIERS[id]\n}\n\n/**\n * Effective fee in bps for a given tier and payment kind.\n * Returns `null` for the enterprise tier (custom-priced).\n */\nexport function effectiveFeeBps(\n tier: MerchantTier,\n kind: 'one_shot' | 'subscription',\n): number | null {\n const def = TIERS[tier]\n if (def.oneShotFeeBps === null) return null\n if (kind === 'one_shot') return def.oneShotFeeBps\n return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0)\n}\n","/**\n * Webhook event names.\n *\n * Wire format is `<resource>.<action>`. Every event payload is versioned at\n * the envelope level so additive changes do not break consumers.\n */\n\nexport const WEBHOOK_EVENTS = {\n payment: {\n created: 'payment.created',\n completed: 'payment.completed',\n failed: 'payment.failed',\n },\n subscription: {\n created: 'subscription.created',\n charged: 'subscription.charged',\n chargeFailed: 'subscription.charge_failed',\n recoveryAttempt: 'subscription.recovery_attempt',\n recoveryOutcome: 'subscription.recovery_outcome',\n cancelled: 'subscription.cancelled',\n lapsed: 'subscription.lapsed',\n },\n refund: {\n created: 'refund.created',\n completed: 'refund.completed',\n failed: 'refund.failed',\n },\n invoice: {\n created: 'invoice.created',\n paid: 'invoice.paid',\n overdue: 'invoice.overdue',\n },\n agent: {\n actionExecuted: 'agent.action_executed',\n jobProposed: 'agent.job_proposed',\n jobCompleted: 'agent.job_completed',\n jobDisputed: 'agent.job_disputed',\n },\n compliance: {\n walletFlagged: 'compliance.wallet_flagged',\n walletBlocked: 'compliance.wallet_blocked',\n },\n} as const\n\nexport type WebhookEventName =\n | (typeof WEBHOOK_EVENTS.payment)[keyof typeof WEBHOOK_EVENTS.payment]\n | (typeof WEBHOOK_EVENTS.subscription)[keyof typeof WEBHOOK_EVENTS.subscription]\n | (typeof WEBHOOK_EVENTS.refund)[keyof typeof WEBHOOK_EVENTS.refund]\n | (typeof WEBHOOK_EVENTS.invoice)[keyof typeof WEBHOOK_EVENTS.invoice]\n | (typeof WEBHOOK_EVENTS.agent)[keyof typeof WEBHOOK_EVENTS.agent]\n | (typeof WEBHOOK_EVENTS.compliance)[keyof typeof WEBHOOK_EVENTS.compliance]\n\nexport const ALL_WEBHOOK_EVENTS: readonly WebhookEventName[] = [\n ...Object.values(WEBHOOK_EVENTS.payment),\n ...Object.values(WEBHOOK_EVENTS.subscription),\n ...Object.values(WEBHOOK_EVENTS.refund),\n ...Object.values(WEBHOOK_EVENTS.invoice),\n ...Object.values(WEBHOOK_EVENTS.agent),\n ...Object.values(WEBHOOK_EVENTS.compliance),\n] as const\n\n/** Exponential backoff schedule for webhook delivery, in seconds. */\nexport const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[] = [\n 60, // 1 minute\n 300, // 5 minutes\n 1_800, // 30 minutes\n 7_200, // 2 hours\n 86_400, // 24 hours\n] as const\n\nexport const WEBHOOK_MAX_ATTEMPTS = WEBHOOK_RETRY_SCHEDULE_SECONDS.length + 1\n\n/** Webhook signatures older than this are rejected to prevent replay. */\nexport const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300\n\n/** HTTP header carrying the HMAC signature. */\nexport const WEBHOOK_SIGNATURE_HEADER = 'strimz-signature'\n\n/** HTTP header carrying the unique delivery id (idempotency key for the receiver). */\nexport const WEBHOOK_DELIVERY_ID_HEADER = 'strimz-delivery-id'\n","/**\n * API key prefix conventions.\n *\n * Prefix tells you immediately which environment a key targets and whether it\n * is safe to expose to the client. Secret keys are server-side only; publishable\n * keys can ship in browser bundles.\n */\n\nimport { parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport type ApiKeyMode = 'test' | 'live'\nexport type ApiKeyKind = 'secret' | 'publishable'\n\nexport const API_KEY_PREFIXES = {\n secret: {\n test: 'sk_test_',\n live: 'sk_live_',\n },\n publishable: {\n test: 'pk_test_',\n live: 'pk_live_',\n },\n} as const satisfies Record<ApiKeyKind, Record<ApiKeyMode, string>>\n\n/** Length of the random portion of a key, before prefix. Base62, 256 bits of entropy. */\nexport const API_KEY_RANDOM_BYTES = 32\n\nexport function prefixFor(kind: ApiKeyKind, mode: ApiKeyMode): string {\n return API_KEY_PREFIXES[kind][mode]\n}\n\nexport function modeFromKey(key: string): ApiKeyMode | null {\n if (key.startsWith('sk_test_') || key.startsWith('pk_test_')) return 'test'\n if (key.startsWith('sk_live_') || key.startsWith('pk_live_')) return 'live'\n return null\n}\n\nexport function kindFromKey(key: string): ApiKeyKind | null {\n if (key.startsWith('sk_')) return 'secret'\n if (key.startsWith('pk_')) return 'publishable'\n return null\n}\n\n/** Number of leading characters of a key safe to display in dashboards/logs. */\nexport const API_KEY_PREFIX_DISPLAY_LENGTH = 12\n\nconst MODE_BY_ENVIRONMENT = {\n testnet: 'test',\n mainnet: 'live',\n} as const satisfies Record<ArcEnvironment, ApiKeyMode>\n\nexport function arcModeFor(env: ArcEnvironment): ApiKeyMode {\n return MODE_BY_ENVIRONMENT[parseArcEnvironment(env)]\n}\n","/**\n * Strimz AutoPay Agent feature flags and defaults.\n *\n * The agent is composed of independent capabilities that can be enabled or\n * disabled per merchant. Defaults are conservative. Merchants opt in to\n * value-moving capabilities (recovery retries, treasury auto-convert).\n */\n\nexport type AgentCapability =\n | 'identity'\n | 'recovery'\n | 'routing'\n | 'cashflow'\n | 'commerce'\n | 'pricing_intelligence'\n\nexport interface AgentCapabilityDescriptor {\n id: AgentCapability\n name: string\n /** Whether the capability moves money or signs transactions. */\n valueMoving: boolean\n /** Default enabled state for a newly created merchant. */\n defaultEnabled: boolean\n}\n\nexport const AGENT_CAPABILITIES: Record<AgentCapability, AgentCapabilityDescriptor> = {\n identity: {\n id: 'identity',\n name: 'Agent Identity (ERC-8004)',\n valueMoving: false,\n defaultEnabled: true,\n },\n recovery: {\n id: 'recovery',\n name: 'Subscription Recovery',\n valueMoving: true,\n defaultEnabled: false,\n },\n routing: {\n id: 'routing',\n name: 'Cross-Chain Payment Routing',\n valueMoving: true,\n defaultEnabled: false,\n },\n cashflow: {\n id: 'cashflow',\n name: 'Treasury Cash Flow Insights',\n valueMoving: false,\n defaultEnabled: false,\n },\n commerce: {\n id: 'commerce',\n name: 'Agentic B2B Commerce (ERC-8183)',\n valueMoving: true,\n defaultEnabled: false,\n },\n pricing_intelligence: {\n id: 'pricing_intelligence',\n name: 'Subscription Pricing Intelligence',\n valueMoving: false,\n defaultEnabled: false,\n },\n}\n\nexport type GracePeriodHours = 24 | 48 | 72\n\nexport const RECOVERY_GRACE_PERIODS: readonly GracePeriodHours[] = [24, 48, 72] as const\n\nexport type RecoveryRetryStrategy = 'once' | 'twice' | 'until_grace_ends'\n\nexport interface AgentDefaultConfig {\n recovery: {\n gracePeriodHours: GracePeriodHours\n strategy: RecoveryRetryStrategy\n }\n cashflow: {\n digestEnabled: boolean\n anomalySensitivity: 'low' | 'medium' | 'high'\n autoConvertToYield: boolean\n }\n commerce: {\n requireHumanApprovalAboveUsdCents: number\n }\n}\n\nexport const AGENT_DEFAULTS: AgentDefaultConfig = {\n recovery: {\n gracePeriodHours: 48,\n strategy: 'twice',\n },\n cashflow: {\n digestEnabled: false,\n anomalySensitivity: 'medium',\n autoConvertToYield: false,\n },\n commerce: {\n requireHumanApprovalAboveUsdCents: 100_000, // $1,000\n },\n}\n\n/** Time-to-live for the agent activity log, in days. */\nexport const AGENT_ACTIVITY_LOG_RETENTION_DAYS = 90\n","/**\n * Circle CCTP V2 contract addresses for Arc.\n *\n * CCTP lets a payer hold USDC on any supported chain (Ethereum, Base, Polygon,\n * Arbitrum, Solana, etc.) and pay a Strimz merchant who receives Arc USDC.\n *\n * @see https://developers.circle.com/stablecoins/cctp-getting-started\n */\n\nimport type { Address } from 'viem'\nimport { parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport interface CCTPContractSet {\n tokenMessengerV2: Address\n messageTransmitterV2: Address\n gatewayWallet: Address\n gatewayMinter: Address\n /** CCTP domain identifier for the destination chain. */\n domainId: number\n}\n\nexport const CCTP_CONTRACTS: Record<ArcEnvironment, CCTPContractSet> = {\n testnet: {\n tokenMessengerV2: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',\n messageTransmitterV2: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',\n gatewayWallet: '0x0077777d7EBA4688BDeF3E311b846F25870A19B9',\n gatewayMinter: '0x0022222ABE238Cc2C7Bb1f21003F0a260052475B',\n domainId: 26,\n },\n mainnet: {\n // Pending Circle's mainnet publication of CCTP V2 addresses for Arc.\n // Testnet values are mirrored as a placeholder so type signatures stay non-null.\n tokenMessengerV2: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',\n messageTransmitterV2: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',\n gatewayWallet: '0x77777777Dcc4d5A8B6E418Fd04D8997ef11000eE',\n gatewayMinter: '0x2222222d7164433c4C09B0b0D809a9b52C04C205',\n domainId: 26,\n },\n}\n\n/** CCTP domain ids for source chains a payer can bridge from. */\nexport const CCTP_DOMAIN_IDS = {\n ethereum: 0,\n avalanche: 1,\n optimism: 2,\n arbitrum: 3,\n noble: 4,\n solana: 5,\n base: 6,\n polygon: 7,\n arc: 26,\n} as const\n\nexport type CCTPSourceChain = keyof typeof CCTP_DOMAIN_IDS\n\nexport const CCTP_SUPPORTED_SOURCE_CHAINS: readonly CCTPSourceChain[] = [\n 'ethereum',\n 'avalanche',\n 'optimism',\n 'arbitrum',\n 'base',\n 'polygon',\n 'solana',\n] as const\n\nexport function getCctpContracts(env: ArcEnvironment): CCTPContractSet {\n return CCTP_CONTRACTS[parseArcEnvironment(env)]\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/chains.ts","../src/tokens.ts","../src/tiers.ts","../src/webhooks.ts","../src/api-keys.ts","../src/agents.ts","../src/cctp.ts"],"names":["defineChain"],"mappings":";;;;;AAaO,IAAM,oBAAA,GAAuB;AAC7B,IAAM,oBAAA,GAAuB;AAEpC,IAAM,WAAA,GAAc;AAAA,EAClB,IAAA,EAAM,MAAA;AAAA,EACN,MAAA,EAAQ,MAAA;AAAA,EACR,QAAA,EAAU;AACZ,CAAA;AAEO,IAAM,aAAoBA,gBAAA,CAAY;AAAA,EAC3C,EAAA,EAAI,oBAAA;AAAA,EACJ,IAAA,EAAM,aAAA;AAAA,EACN,cAAA,EAAgB,WAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP,OAAA,EAAS,EAAE,IAAA,EAAM,CAAC,4BAA4B,CAAA,EAA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AA;AAAA,EACN,OAAA,EAAS,CAAA;AAAA,EACT,GAAA,EAAK;AACP;AAIO,IAAM,4BAAA,GAA2D;AAAA,EACtE,UAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF;AAEO,SAAS,iBAAiB,GAAA,EAAsC;AACrE,EAAA,OAAO,cAAA,CAAe,mBAAA,CAAoB,GAAG,CAAC,CAAA;AAChD","file":"index.cjs","sourcesContent":["/**\n * Arc blockchain definitions.\n *\n * Arc is Circle's stablecoin-native L1 where gas is paid in USDC.\n * - Testnet is live (chain id 5042002).\n * - Mainnet beta is expected in 2026; the mainnet entry is a placeholder\n * until Circle publishes the production chain id and RPC endpoint.\n *\n * @see https://docs.arc.network\n */\n\nimport { defineChain, type Chain } from 'viem'\n\nexport const ARC_TESTNET_CHAIN_ID = 5042002 as const\nexport const ARC_MAINNET_CHAIN_ID = 5042 as const\n\nconst NATIVE_USDC = {\n name: 'USDC',\n symbol: 'USDC',\n decimals: 18,\n} as const\n\nexport const arcTestnet: Chain = defineChain({\n id: ARC_TESTNET_CHAIN_ID,\n name: 'Arc Testnet',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.testnet.arc.io'] },\n public: { http: ['https://rpc.testnet.arc.io'] },\n },\n blockExplorers: {\n default: {\n name: 'Arc Testnet Explorer',\n url: 'https://explorer.testnet.arc.io',\n },\n },\n testnet: true,\n})\n\nexport const arcMainnet: Chain = defineChain({\n id: ARC_MAINNET_CHAIN_ID,\n name: 'Arc',\n nativeCurrency: NATIVE_USDC,\n rpcUrls: {\n default: { http: ['https://rpc.mainnet.arc.io'] },\n public: { http: ['https://rpc.mainnet.arc.io'] },\n },\n blockExplorers: {\n default: {\n name: 'Arc Explorer',\n url: 'https://explorer.arc.io',\n },\n },\n testnet: false,\n})\n\nexport type ArcEnvironment = 'testnet' | 'mainnet'\n\nexport const ARC_CHAINS: Record<ArcEnvironment, Chain> = {\n testnet: arcTestnet,\n mainnet: arcMainnet,\n}\n\nexport const ARC_ENVIRONMENTS: readonly ArcEnvironment[] = ['testnet', 'mainnet'] as const\n\nexport function isArcEnvironment(value: unknown): value is ArcEnvironment {\n return typeof value === 'string' && (ARC_ENVIRONMENTS as readonly string[]).includes(value)\n}\n\nexport function parseArcEnvironment(value: unknown): ArcEnvironment {\n if (isArcEnvironment(value)) return value\n throw new Error(\n `unknown Arc environment ${JSON.stringify(value)}: expected one of ${ARC_ENVIRONMENTS.join(', ')}`,\n )\n}\n\nexport function getArcChain(env: ArcEnvironment): Chain {\n return ARC_CHAINS[parseArcEnvironment(env)]\n}\n\nexport function getArcExplorerUrl(env: ArcEnvironment): string {\n const explorer = getArcChain(env).blockExplorers?.default.url\n if (!explorer) throw new Error(`Arc ${env} has no block explorer configured`)\n return explorer\n}\n\nexport function arcExplorerTxUrl(env: ArcEnvironment, txHash: string): string {\n return `${getArcExplorerUrl(env)}/tx/${txHash}`\n}\n\nexport function arcEnvironmentForChainId(chainId: number): ArcEnvironment {\n const env = ARC_ENVIRONMENTS.find((candidate) => ARC_CHAINS[candidate].id === chainId)\n if (!env) {\n throw new Error(\n `chain id ${chainId} is not an Arc chain: expected ${ARC_TESTNET_CHAIN_ID} (testnet) or ${ARC_MAINNET_CHAIN_ID} (mainnet)`,\n )\n }\n return env\n}\n\nexport function assertArcChainId(env: ArcEnvironment, rpcChainId: number): void {\n const expected = getArcChain(env).id\n if (rpcChainId !== expected) {\n throw new Error(\n `ARC_RPC_URL serves chain id ${rpcChainId}, but ARC_ENVIRONMENT=${env} expects chain id ${expected}`,\n )\n }\n}\n\nexport function isArcChain(chainId: number): boolean {\n return chainId === ARC_TESTNET_CHAIN_ID || chainId === ARC_MAINNET_CHAIN_ID\n}\n","/**\n * Token registry for Arc.\n *\n * USDC and EURC are first-class payment tokens. They can be requested in a\n * payment session and used as a subscription currency.\n *\n * USYC is yield-bearing and is treated as a treasury asset only. Merchants\n * can hold it and earn yield, but a payer cannot pay in USYC.\n */\n\nimport type { Address } from 'viem'\nimport { getArcChain, parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport type TokenSymbol = 'USDC' | 'EURC' | 'USYC'\n\n/** Tokens accepted as direct payment by Strimz. USYC is excluded by design. */\nexport type PaymentToken = Extract<TokenSymbol, 'USDC' | 'EURC'>\n\nexport const PAYMENT_TOKENS: readonly PaymentToken[] = ['USDC', 'EURC'] as const\n\nexport interface TokenDescriptor {\n symbol: TokenSymbol\n name: string\n decimals: number\n /** Whether the token is accepted as direct payment. */\n paymentEligible: boolean\n /** Whether the token is yield-bearing. */\n yieldBearing: boolean\n}\n\nexport interface TokenAddress {\n symbol: TokenSymbol\n address: Address\n chainId: number\n}\n\nexport const TOKENS: Record<TokenSymbol, TokenDescriptor> = {\n USDC: {\n symbol: 'USDC',\n name: 'USD Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n EURC: {\n symbol: 'EURC',\n name: 'Euro Coin',\n decimals: 6,\n paymentEligible: true,\n yieldBearing: false,\n },\n USYC: {\n symbol: 'USYC',\n name: 'US Yield Coin',\n decimals: 6,\n paymentEligible: false,\n yieldBearing: true,\n },\n}\n\n/**\n * Native, Circle-issued addresses on Arc.\n * The same address is reused across testnet and mainnet for native tokens\n * since Arc preserves canonical addresses across environments where possible.\n */\nexport const TOKEN_ADDRESSES: Record<ArcEnvironment, Record<TokenSymbol, Address>> = {\n testnet: {\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',\n USYC: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C',\n },\n mainnet: {\n // Mainnet addresses pending Arc mainnet beta launch; placeholders mirror\n // testnet for now and must be replaced when Circle publishes the canonical\n // mainnet token registry.\n USDC: '0x3600000000000000000000000000000000000000',\n EURC: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',\n USYC: '0x8a5D989Bbb96929F689B0200f435f53dA42bF490',\n },\n}\n\nexport function getTokenAddress(env: ArcEnvironment, symbol: TokenSymbol): Address {\n return TOKEN_ADDRESSES[parseArcEnvironment(env)][symbol]\n}\n\nexport function getTokenBySymbol(symbol: string): TokenDescriptor | undefined {\n return (TOKENS as Record<string, TokenDescriptor>)[symbol]\n}\n\nexport function isPaymentToken(symbol: string): symbol is PaymentToken {\n return PAYMENT_TOKENS.includes(symbol as PaymentToken)\n}\n\nexport function chainIdFor(env: ArcEnvironment): number {\n return getArcChain(env).id\n}\n","/**\n * Strimz pricing tiers.\n *\n * Fees are expressed in basis points (bps): 100 bps = 1%.\n * The subscription premium is added to the per-transaction rate when the\n * payment is recurring (i.e. originated from a SubscriptionPlan).\n */\n\nimport { PAYMENT_TOKENS, TOKENS, type PaymentToken } from './tokens.js'\n\nexport type MerchantTier = 'free' | 'starter' | 'growth' | 'enterprise'\n\nexport type VolumePlan = Exclude<MerchantTier, 'enterprise'>\n\nexport type PlanFeature = 'storefront' | 'anomaly_alerts' | 'yield_recommendations'\n\nexport interface PlanDefinition {\n id: MerchantTier\n name: string\n feeBps: number | null\n entersAtVolume: number | null\n features: readonly PlanFeature[]\n prioritySupport: boolean\n}\n\nconst PAID_FEATURES: readonly PlanFeature[] = [\n 'storefront',\n 'anomaly_alerts',\n 'yield_recommendations',\n]\n\nexport const PLANS: Record<MerchantTier, PlanDefinition> = {\n free: {\n id: 'free',\n name: 'Free',\n feeBps: 0,\n entersAtVolume: 0,\n features: [],\n prioritySupport: false,\n },\n starter: {\n id: 'starter',\n name: 'Starter',\n feeBps: 50,\n entersAtVolume: 1_000,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n growth: {\n id: 'growth',\n name: 'Growth',\n feeBps: 40,\n entersAtVolume: 50_000,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n enterprise: {\n id: 'enterprise',\n name: 'Enterprise',\n feeBps: null,\n entersAtVolume: null,\n features: PAID_FEATURES,\n prioritySupport: true,\n },\n}\n\nexport const DEFAULT_TIER: MerchantTier = 'free'\n\nconst PLAN_ORDER: readonly MerchantTier[] = ['free', 'starter', 'growth', 'enterprise']\n\nconst VOLUME_PLANS: readonly VolumePlan[] = ['free', 'starter', 'growth']\n\nexport const PLAN_FEE_CEILING_BPS: number = Math.max(\n ...VOLUME_PLANS.map((plan) => PLANS[plan].feeBps ?? 0),\n)\n\nexport function planFeeBps(plan: MerchantTier): number | null {\n return PLANS[plan].feeBps\n}\n\nexport function planIncludes(plan: MerchantTier, feature: PlanFeature): boolean {\n return PLANS[plan].features.includes(feature)\n}\n\nexport function plansWith(feature: PlanFeature): MerchantTier[] {\n return PLAN_ORDER.filter((plan) => planIncludes(plan, feature))\n}\n\nexport function lowestPlanWith(feature: PlanFeature): MerchantTier {\n const plan = PLAN_ORDER.find((candidate) => planIncludes(candidate, feature))\n if (!plan) throw new Error(`no plan includes ${feature}`)\n return plan\n}\n\nexport type PaymentVolumes = Readonly<Record<PaymentToken, bigint>>\n\nfunction thresholdInBaseUnits(plan: VolumePlan, token: PaymentToken): bigint {\n const wholeUnits = PLANS[plan].entersAtVolume\n if (wholeUnits === null) throw new Error(`${plan} has no volume threshold`)\n return BigInt(wholeUnits) * 10n ** BigInt(TOKENS[token].decimals)\n}\n\nexport function planForVolume(volumes: PaymentVolumes): VolumePlan {\n let reached: VolumePlan = 'free'\n for (const plan of VOLUME_PLANS) {\n if (PAYMENT_TOKENS.some((token) => volumes[token] >= thresholdInBaseUnits(plan, token))) {\n reached = plan\n }\n }\n return reached\n}\n\nexport function planUpgradeFor(current: MerchantTier, volumes: PaymentVolumes): VolumePlan | null {\n if (current === 'enterprise') return null\n const earned = planForVolume(volumes)\n return PLAN_ORDER.indexOf(earned) > PLAN_ORDER.indexOf(current) ? earned : null\n}\n","/**\n * Webhook event names.\n *\n * Wire format is `<resource>.<action>`. Every event payload is versioned at\n * the envelope level so additive changes do not break consumers.\n */\n\nexport const WEBHOOK_EVENTS = {\n payment: {\n created: 'payment.created',\n completed: 'payment.completed',\n failed: 'payment.failed',\n },\n subscription: {\n created: 'subscription.created',\n charged: 'subscription.charged',\n chargeFailed: 'subscription.charge_failed',\n recoveryAttempt: 'subscription.recovery_attempt',\n recoveryOutcome: 'subscription.recovery_outcome',\n cancelled: 'subscription.cancelled',\n lapsed: 'subscription.lapsed',\n },\n refund: {\n created: 'refund.created',\n completed: 'refund.completed',\n failed: 'refund.failed',\n },\n invoice: {\n created: 'invoice.created',\n paid: 'invoice.paid',\n overdue: 'invoice.overdue',\n },\n agent: {\n actionExecuted: 'agent.action_executed',\n jobProposed: 'agent.job_proposed',\n jobCompleted: 'agent.job_completed',\n jobDisputed: 'agent.job_disputed',\n },\n compliance: {\n walletFlagged: 'compliance.wallet_flagged',\n walletBlocked: 'compliance.wallet_blocked',\n },\n} as const\n\nexport type WebhookEventName =\n | (typeof WEBHOOK_EVENTS.payment)[keyof typeof WEBHOOK_EVENTS.payment]\n | (typeof WEBHOOK_EVENTS.subscription)[keyof typeof WEBHOOK_EVENTS.subscription]\n | (typeof WEBHOOK_EVENTS.refund)[keyof typeof WEBHOOK_EVENTS.refund]\n | (typeof WEBHOOK_EVENTS.invoice)[keyof typeof WEBHOOK_EVENTS.invoice]\n | (typeof WEBHOOK_EVENTS.agent)[keyof typeof WEBHOOK_EVENTS.agent]\n | (typeof WEBHOOK_EVENTS.compliance)[keyof typeof WEBHOOK_EVENTS.compliance]\n\nexport const ALL_WEBHOOK_EVENTS: readonly WebhookEventName[] = [\n ...Object.values(WEBHOOK_EVENTS.payment),\n ...Object.values(WEBHOOK_EVENTS.subscription),\n ...Object.values(WEBHOOK_EVENTS.refund),\n ...Object.values(WEBHOOK_EVENTS.invoice),\n ...Object.values(WEBHOOK_EVENTS.agent),\n ...Object.values(WEBHOOK_EVENTS.compliance),\n] as const\n\n/** Exponential backoff schedule for webhook delivery, in seconds. */\nexport const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[] = [\n 60, // 1 minute\n 300, // 5 minutes\n 1_800, // 30 minutes\n 7_200, // 2 hours\n 86_400, // 24 hours\n] as const\n\nexport const WEBHOOK_MAX_ATTEMPTS = WEBHOOK_RETRY_SCHEDULE_SECONDS.length + 1\n\n/** Webhook signatures older than this are rejected to prevent replay. */\nexport const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300\n\n/** HTTP header carrying the HMAC signature. */\nexport const WEBHOOK_SIGNATURE_HEADER = 'strimz-signature'\n\n/** HTTP header carrying the unique delivery id (idempotency key for the receiver). */\nexport const WEBHOOK_DELIVERY_ID_HEADER = 'strimz-delivery-id'\n","/**\n * API key prefix conventions.\n *\n * Prefix tells you immediately which environment a key targets and whether it\n * is safe to expose to the client. Secret keys are server-side only; publishable\n * keys can ship in browser bundles.\n */\n\nimport { parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport type ApiKeyMode = 'test' | 'live'\nexport type ApiKeyKind = 'secret' | 'publishable'\n\nexport const API_KEY_PREFIXES = {\n secret: {\n test: 'sk_test_',\n live: 'sk_live_',\n },\n publishable: {\n test: 'pk_test_',\n live: 'pk_live_',\n },\n} as const satisfies Record<ApiKeyKind, Record<ApiKeyMode, string>>\n\n/** Length of the random portion of a key, before prefix. Base62, 256 bits of entropy. */\nexport const API_KEY_RANDOM_BYTES = 32\n\nexport function prefixFor(kind: ApiKeyKind, mode: ApiKeyMode): string {\n return API_KEY_PREFIXES[kind][mode]\n}\n\nexport function modeFromKey(key: string): ApiKeyMode | null {\n if (key.startsWith('sk_test_') || key.startsWith('pk_test_')) return 'test'\n if (key.startsWith('sk_live_') || key.startsWith('pk_live_')) return 'live'\n return null\n}\n\nexport function kindFromKey(key: string): ApiKeyKind | null {\n if (key.startsWith('sk_')) return 'secret'\n if (key.startsWith('pk_')) return 'publishable'\n return null\n}\n\n/** Number of leading characters of a key safe to display in dashboards/logs. */\nexport const API_KEY_PREFIX_DISPLAY_LENGTH = 12\n\nconst MODE_BY_ENVIRONMENT = {\n testnet: 'test',\n mainnet: 'live',\n} as const satisfies Record<ArcEnvironment, ApiKeyMode>\n\nexport function arcModeFor(env: ArcEnvironment): ApiKeyMode {\n return MODE_BY_ENVIRONMENT[parseArcEnvironment(env)]\n}\n","/**\n * Strimz AutoPay Agent feature flags and defaults.\n *\n * The agent is composed of independent capabilities that can be enabled or\n * disabled per merchant. Defaults are conservative. Merchants opt in to\n * value-moving capabilities (recovery retries, treasury auto-convert).\n */\n\nexport type AgentCapability =\n | 'identity'\n | 'recovery'\n | 'routing'\n | 'cashflow'\n | 'commerce'\n | 'pricing_intelligence'\n\nexport interface AgentCapabilityDescriptor {\n id: AgentCapability\n name: string\n /** Whether the capability moves money or signs transactions. */\n valueMoving: boolean\n /** Default enabled state for a newly created merchant. */\n defaultEnabled: boolean\n}\n\nexport const AGENT_CAPABILITIES: Record<AgentCapability, AgentCapabilityDescriptor> = {\n identity: {\n id: 'identity',\n name: 'Agent Identity (ERC-8004)',\n valueMoving: false,\n defaultEnabled: true,\n },\n recovery: {\n id: 'recovery',\n name: 'Subscription Recovery',\n valueMoving: true,\n defaultEnabled: false,\n },\n routing: {\n id: 'routing',\n name: 'Cross-Chain Payment Routing',\n valueMoving: true,\n defaultEnabled: false,\n },\n cashflow: {\n id: 'cashflow',\n name: 'Treasury Cash Flow Insights',\n valueMoving: false,\n defaultEnabled: false,\n },\n commerce: {\n id: 'commerce',\n name: 'Agentic B2B Commerce (ERC-8183)',\n valueMoving: true,\n defaultEnabled: false,\n },\n pricing_intelligence: {\n id: 'pricing_intelligence',\n name: 'Subscription Pricing Intelligence',\n valueMoving: false,\n defaultEnabled: false,\n },\n}\n\nexport type GracePeriodHours = 24 | 48 | 72\n\nexport const RECOVERY_GRACE_PERIODS: readonly GracePeriodHours[] = [24, 48, 72] as const\n\nexport type RecoveryRetryStrategy = 'once' | 'twice' | 'until_grace_ends'\n\nexport interface AgentDefaultConfig {\n recovery: {\n gracePeriodHours: GracePeriodHours\n strategy: RecoveryRetryStrategy\n }\n cashflow: {\n digestEnabled: boolean\n anomalySensitivity: 'low' | 'medium' | 'high'\n autoConvertToYield: boolean\n }\n commerce: {\n requireHumanApprovalAboveUsdCents: number\n }\n}\n\nexport const AGENT_DEFAULTS: AgentDefaultConfig = {\n recovery: {\n gracePeriodHours: 48,\n strategy: 'twice',\n },\n cashflow: {\n digestEnabled: false,\n anomalySensitivity: 'medium',\n autoConvertToYield: false,\n },\n commerce: {\n requireHumanApprovalAboveUsdCents: 100_000, // $1,000\n },\n}\n\n/** Time-to-live for the agent activity log, in days. */\nexport const AGENT_ACTIVITY_LOG_RETENTION_DAYS = 90\n","/**\n * Circle CCTP V2 contract addresses for Arc.\n *\n * CCTP lets a payer hold USDC on any supported chain (Ethereum, Base, Polygon,\n * Arbitrum, Solana, etc.) and pay a Strimz merchant who receives Arc USDC.\n *\n * @see https://developers.circle.com/stablecoins/cctp-getting-started\n */\n\nimport type { Address } from 'viem'\nimport { parseArcEnvironment, type ArcEnvironment } from './chains.js'\n\nexport interface CCTPContractSet {\n tokenMessengerV2: Address\n messageTransmitterV2: Address\n gatewayWallet: Address\n gatewayMinter: Address\n /** CCTP domain identifier for the destination chain. */\n domainId: number\n}\n\nexport const CCTP_CONTRACTS: Record<ArcEnvironment, CCTPContractSet> = {\n testnet: {\n tokenMessengerV2: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',\n messageTransmitterV2: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',\n gatewayWallet: '0x0077777d7EBA4688BDeF3E311b846F25870A19B9',\n gatewayMinter: '0x0022222ABE238Cc2C7Bb1f21003F0a260052475B',\n domainId: 26,\n },\n mainnet: {\n // Pending Circle's mainnet publication of CCTP V2 addresses for Arc.\n // Testnet values are mirrored as a placeholder so type signatures stay non-null.\n tokenMessengerV2: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',\n messageTransmitterV2: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',\n gatewayWallet: '0x77777777Dcc4d5A8B6E418Fd04D8997ef11000eE',\n gatewayMinter: '0x2222222d7164433c4C09B0b0D809a9b52C04C205',\n domainId: 26,\n },\n}\n\n/** CCTP domain ids for source chains a payer can bridge from. */\nexport const CCTP_DOMAIN_IDS = {\n ethereum: 0,\n avalanche: 1,\n optimism: 2,\n arbitrum: 3,\n noble: 4,\n solana: 5,\n base: 6,\n polygon: 7,\n arc: 26,\n} as const\n\nexport type CCTPSourceChain = keyof typeof CCTP_DOMAIN_IDS\n\nexport const CCTP_SUPPORTED_SOURCE_CHAINS: readonly CCTPSourceChain[] = [\n 'ethereum',\n 'avalanche',\n 'optimism',\n 'arbitrum',\n 'base',\n 'polygon',\n 'solana',\n] as const\n\nexport function getCctpContracts(env: ArcEnvironment): CCTPContractSet {\n return CCTP_CONTRACTS[parseArcEnvironment(env)]\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ARC_CHAINS, ARC_ENVIRONMENTS, ARC_MAINNET_CHAIN_ID, ARC_TESTNET_CHAIN_ID, ArcEnvironment, arcEnvironmentForChainId, arcExplorerTxUrl, arcMainnet, arcTestnet, assertArcChainId, getArcChain, getArcExplorerUrl, isArcChain, isArcEnvironment, parseArcEnvironment } from './chains.cjs';
|
|
2
2
|
export { PAYMENT_TOKENS, PaymentToken, TOKENS, TOKEN_ADDRESSES, TokenAddress, TokenDescriptor, TokenSymbol, chainIdFor, getTokenAddress, getTokenBySymbol, isPaymentToken } from './tokens.cjs';
|
|
3
|
-
export { DEFAULT_TIER, MerchantTier,
|
|
3
|
+
export { DEFAULT_TIER, MerchantTier, PLANS, PLAN_FEE_CEILING_BPS, PaymentVolumes, PlanDefinition, PlanFeature, VolumePlan, lowestPlanWith, planFeeBps, planForVolume, planIncludes, planUpgradeFor, plansWith } from './tiers.cjs';
|
|
4
4
|
export { ALL_WEBHOOK_EVENTS, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENTS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_SCHEDULE_SECONDS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, WebhookEventName } from './webhooks.cjs';
|
|
5
5
|
export { API_KEY_PREFIXES, API_KEY_PREFIX_DISPLAY_LENGTH, API_KEY_RANDOM_BYTES, ApiKeyKind, ApiKeyMode, arcModeFor, kindFromKey, modeFromKey, prefixFor } from './api-keys.cjs';
|
|
6
6
|
export { AGENT_ACTIVITY_LOG_RETENTION_DAYS, AGENT_CAPABILITIES, AGENT_DEFAULTS, AgentCapability, AgentCapabilityDescriptor, AgentDefaultConfig, GracePeriodHours, RECOVERY_GRACE_PERIODS, RecoveryRetryStrategy } from './agents.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ARC_CHAINS, ARC_ENVIRONMENTS, ARC_MAINNET_CHAIN_ID, ARC_TESTNET_CHAIN_ID, ArcEnvironment, arcEnvironmentForChainId, arcExplorerTxUrl, arcMainnet, arcTestnet, assertArcChainId, getArcChain, getArcExplorerUrl, isArcChain, isArcEnvironment, parseArcEnvironment } from './chains.js';
|
|
2
2
|
export { PAYMENT_TOKENS, PaymentToken, TOKENS, TOKEN_ADDRESSES, TokenAddress, TokenDescriptor, TokenSymbol, chainIdFor, getTokenAddress, getTokenBySymbol, isPaymentToken } from './tokens.js';
|
|
3
|
-
export { DEFAULT_TIER, MerchantTier,
|
|
3
|
+
export { DEFAULT_TIER, MerchantTier, PLANS, PLAN_FEE_CEILING_BPS, PaymentVolumes, PlanDefinition, PlanFeature, VolumePlan, lowestPlanWith, planFeeBps, planForVolume, planIncludes, planUpgradeFor, plansWith } from './tiers.js';
|
|
4
4
|
export { ALL_WEBHOOK_EVENTS, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENTS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_SCHEDULE_SECONDS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, WebhookEventName } from './webhooks.js';
|
|
5
5
|
export { API_KEY_PREFIXES, API_KEY_PREFIX_DISPLAY_LENGTH, API_KEY_RANDOM_BYTES, ApiKeyKind, ApiKeyMode, arcModeFor, kindFromKey, modeFromKey, prefixFor } from './api-keys.js';
|
|
6
6
|
export { AGENT_ACTIVITY_LOG_RETENTION_DAYS, AGENT_CAPABILITIES, AGENT_DEFAULTS, AgentCapability, AgentCapabilityDescriptor, AgentDefaultConfig, GracePeriodHours, RECOVERY_GRACE_PERIODS, RecoveryRetryStrategy } from './agents.js';
|
package/dist/index.js
CHANGED
|
@@ -140,68 +140,83 @@ function chainIdFor(env) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
// src/tiers.ts
|
|
143
|
-
var
|
|
143
|
+
var PAID_FEATURES = [
|
|
144
|
+
"storefront",
|
|
145
|
+
"anomaly_alerts",
|
|
146
|
+
"yield_recommendations"
|
|
147
|
+
];
|
|
148
|
+
var PLANS = {
|
|
144
149
|
free: {
|
|
145
150
|
id: "free",
|
|
146
151
|
name: "Free",
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
subscriptionPremiumBps: 20,
|
|
151
|
-
// +0.2% on recurring => 1.7% effective
|
|
152
|
-
monthlyVolumeCapUsdCents: 1e6,
|
|
153
|
-
// $10,000
|
|
154
|
-
whiteLabelEligible: false,
|
|
152
|
+
feeBps: 0,
|
|
153
|
+
entersAtVolume: 0,
|
|
154
|
+
features: [],
|
|
155
155
|
prioritySupport: false
|
|
156
156
|
},
|
|
157
|
+
starter: {
|
|
158
|
+
id: "starter",
|
|
159
|
+
name: "Starter",
|
|
160
|
+
feeBps: 50,
|
|
161
|
+
entersAtVolume: 1e3,
|
|
162
|
+
features: PAID_FEATURES,
|
|
163
|
+
prioritySupport: true
|
|
164
|
+
},
|
|
157
165
|
growth: {
|
|
158
166
|
id: "growth",
|
|
159
167
|
name: "Growth",
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// 0.8%
|
|
164
|
-
subscriptionPremiumBps: 20,
|
|
165
|
-
// 1.0% effective
|
|
166
|
-
monthlyVolumeCapUsdCents: 1e7,
|
|
167
|
-
// $100,000
|
|
168
|
-
whiteLabelEligible: true,
|
|
169
|
-
prioritySupport: false
|
|
170
|
-
},
|
|
171
|
-
business: {
|
|
172
|
-
id: "business",
|
|
173
|
-
name: "Business",
|
|
174
|
-
monthlyFeeUsdCents: 19900,
|
|
175
|
-
// $199
|
|
176
|
-
oneShotFeeBps: 50,
|
|
177
|
-
// 0.5%
|
|
178
|
-
subscriptionPremiumBps: 20,
|
|
179
|
-
// 0.7% effective
|
|
180
|
-
monthlyVolumeCapUsdCents: 1e8,
|
|
181
|
-
// $1,000,000
|
|
182
|
-
whiteLabelEligible: true,
|
|
168
|
+
feeBps: 40,
|
|
169
|
+
entersAtVolume: 5e4,
|
|
170
|
+
features: PAID_FEATURES,
|
|
183
171
|
prioritySupport: true
|
|
184
172
|
},
|
|
185
173
|
enterprise: {
|
|
186
174
|
id: "enterprise",
|
|
187
175
|
name: "Enterprise",
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
monthlyVolumeCapUsdCents: null,
|
|
192
|
-
whiteLabelEligible: true,
|
|
176
|
+
feeBps: null,
|
|
177
|
+
entersAtVolume: null,
|
|
178
|
+
features: PAID_FEATURES,
|
|
193
179
|
prioritySupport: true
|
|
194
180
|
}
|
|
195
181
|
};
|
|
196
182
|
var DEFAULT_TIER = "free";
|
|
197
|
-
|
|
198
|
-
|
|
183
|
+
var PLAN_ORDER = ["free", "starter", "growth", "enterprise"];
|
|
184
|
+
var VOLUME_PLANS = ["free", "starter", "growth"];
|
|
185
|
+
var PLAN_FEE_CEILING_BPS = Math.max(
|
|
186
|
+
...VOLUME_PLANS.map((plan) => PLANS[plan].feeBps ?? 0)
|
|
187
|
+
);
|
|
188
|
+
function planFeeBps(plan) {
|
|
189
|
+
return PLANS[plan].feeBps;
|
|
190
|
+
}
|
|
191
|
+
function planIncludes(plan, feature) {
|
|
192
|
+
return PLANS[plan].features.includes(feature);
|
|
193
|
+
}
|
|
194
|
+
function plansWith(feature) {
|
|
195
|
+
return PLAN_ORDER.filter((plan) => planIncludes(plan, feature));
|
|
196
|
+
}
|
|
197
|
+
function lowestPlanWith(feature) {
|
|
198
|
+
const plan = PLAN_ORDER.find((candidate) => planIncludes(candidate, feature));
|
|
199
|
+
if (!plan) throw new Error(`no plan includes ${feature}`);
|
|
200
|
+
return plan;
|
|
201
|
+
}
|
|
202
|
+
function thresholdInBaseUnits(plan, token) {
|
|
203
|
+
const wholeUnits = PLANS[plan].entersAtVolume;
|
|
204
|
+
if (wholeUnits === null) throw new Error(`${plan} has no volume threshold`);
|
|
205
|
+
return BigInt(wholeUnits) * 10n ** BigInt(TOKENS[token].decimals);
|
|
206
|
+
}
|
|
207
|
+
function planForVolume(volumes) {
|
|
208
|
+
let reached = "free";
|
|
209
|
+
for (const plan of VOLUME_PLANS) {
|
|
210
|
+
if (PAYMENT_TOKENS.some((token) => volumes[token] >= thresholdInBaseUnits(plan, token))) {
|
|
211
|
+
reached = plan;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return reached;
|
|
199
215
|
}
|
|
200
|
-
function
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return def.oneShotFeeBps + (def.subscriptionPremiumBps ?? 0);
|
|
216
|
+
function planUpgradeFor(current, volumes) {
|
|
217
|
+
if (current === "enterprise") return null;
|
|
218
|
+
const earned = planForVolume(volumes);
|
|
219
|
+
return PLAN_ORDER.indexOf(earned) > PLAN_ORDER.indexOf(current) ? earned : null;
|
|
205
220
|
}
|
|
206
221
|
|
|
207
222
|
// src/webhooks.ts
|
|
@@ -400,6 +415,6 @@ function getCctpContracts(env) {
|
|
|
400
415
|
return CCTP_CONTRACTS[parseArcEnvironment(env)];
|
|
401
416
|
}
|
|
402
417
|
|
|
403
|
-
export { AGENT_ACTIVITY_LOG_RETENTION_DAYS, AGENT_CAPABILITIES, AGENT_DEFAULTS, ALL_WEBHOOK_EVENTS, API_KEY_PREFIXES, API_KEY_PREFIX_DISPLAY_LENGTH, API_KEY_RANDOM_BYTES, ARC_CHAINS, ARC_ENVIRONMENTS, ARC_MAINNET_CHAIN_ID, ARC_TESTNET_CHAIN_ID, CCTP_CONTRACTS, CCTP_DOMAIN_IDS, CCTP_SUPPORTED_SOURCE_CHAINS, DEFAULT_TIER, PAYMENT_TOKENS,
|
|
418
|
+
export { AGENT_ACTIVITY_LOG_RETENTION_DAYS, AGENT_CAPABILITIES, AGENT_DEFAULTS, ALL_WEBHOOK_EVENTS, API_KEY_PREFIXES, API_KEY_PREFIX_DISPLAY_LENGTH, API_KEY_RANDOM_BYTES, ARC_CHAINS, ARC_ENVIRONMENTS, ARC_MAINNET_CHAIN_ID, ARC_TESTNET_CHAIN_ID, CCTP_CONTRACTS, CCTP_DOMAIN_IDS, CCTP_SUPPORTED_SOURCE_CHAINS, DEFAULT_TIER, PAYMENT_TOKENS, PLANS, PLAN_FEE_CEILING_BPS, RECOVERY_GRACE_PERIODS, TOKENS, TOKEN_ADDRESSES, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENTS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_SCHEDULE_SECONDS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, arcEnvironmentForChainId, arcExplorerTxUrl, arcMainnet, arcModeFor, arcTestnet, assertArcChainId, chainIdFor, getArcChain, getArcExplorerUrl, getCctpContracts, getTokenAddress, getTokenBySymbol, isArcChain, isArcEnvironment, isPaymentToken, kindFromKey, lowestPlanWith, modeFromKey, parseArcEnvironment, planFeeBps, planForVolume, planIncludes, planUpgradeFor, plansWith, prefixFor };
|
|
404
419
|
//# sourceMappingURL=index.js.map
|
|
405
420
|
//# sourceMappingURL=index.js.map
|