fusebox-sdk 0.0.0-stage → 0.1.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/dist/abi.js ADDED
@@ -0,0 +1,5 @@
1
+ // Generated from contracts/out by the Fusebox build (do not edit by hand).
2
+ export const fuseboxWalletAbi = [{ "type": "constructor", "inputs": [{ "name": "registry_", "type": "address", "internalType": "contract FuseRegistry" }, { "name": "owner_", "type": "address", "internalType": "address" }, { "name": "agents", "type": "address[]", "internalType": "address[]" }], "stateMutability": "nonpayable" }, { "type": "receive", "stateMutability": "payable" }, { "type": "function", "name": "BLEW", "inputs": [], "outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }], "stateMutability": "view" }, { "type": "function", "name": "FAILED", "inputs": [], "outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }], "stateMutability": "view" }, { "type": "function", "name": "FUSE_GAS", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "MAX_FUSES", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "PASS", "inputs": [], "outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }], "stateMutability": "view" }, { "type": "function", "name": "UNTRUSTED", "inputs": [], "outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }], "stateMutability": "view" }, { "type": "function", "name": "acceptOwnership", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "addFuse", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }, { "name": "params", "type": "tuple", "internalType": "struct Sockets.Params", "components": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "unit", "type": "uint128", "internalType": "uint128" }, { "name": "a", "type": "uint8", "internalType": "uint8" }, { "name": "b", "type": "uint8", "internalType": "uint8" }] }, { "name": "maxFee", "type": "uint96", "internalType": "uint96" }], "outputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "addPayee", "inputs": [{ "name": "payee", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "allowedCount", "inputs": [], "outputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "approvalEpoch", "inputs": [], "outputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "approvalMaskOf", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "to", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }], "stateMutability": "view" }, { "type": "function", "name": "approvalTtl", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "approvals", "inputs": [{ "name": "intent", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "mask", "type": "uint8", "internalType": "uint8" }, { "name": "expiresAt", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "approvePayment", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "to", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "intent", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "approvers", "inputs": [], "outputs": [{ "name": "", "type": "address[3]", "internalType": "address[3]" }], "stateMutability": "view" }, { "type": "function", "name": "blockedCount", "inputs": [], "outputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "blockedToday", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "check", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "to", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "allowed", "type": "bool", "internalType": "bool" }, { "name": "status", "type": "uint8[]", "internalType": "uint8[]" }, { "name": "inputs", "type": "bytes[]", "internalType": "bytes[]" }, { "name": "outputs", "type": "bytes[]", "internalType": "bytes[]" }], "stateMutability": "view" }, { "type": "function", "name": "counterDay", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "decisionCount", "inputs": [], "outputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "decisionsToday", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "execute", "inputs": [{ "name": "target", "type": "address", "internalType": "address" }, { "name": "value", "type": "uint256", "internalType": "uint256" }, { "name": "data", "type": "bytes", "internalType": "bytes" }], "outputs": [{ "name": "result", "type": "bytes", "internalType": "bytes" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "freeze", "inputs": [], "outputs": [{ "name": "latched", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "fuseCount", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "intentHash", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "to", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "isAgent", "inputs": [{ "name": "", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "maxBlockedPerDay", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "maxDecisionsPerDay", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "owner", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "paused", "inputs": [], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "pay", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "to", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }, { "name": "memo", "type": "string", "internalType": "string" }], "outputs": [{ "name": "allowed", "type": "bool", "internalType": "bool" }, { "name": "decisionId", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "payeeAddedAt", "inputs": [{ "name": "payee", "type": "address", "internalType": "address" }], "outputs": [{ "name": "addedAt", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "pendingOwner", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "pulse", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }, { "name": "set", "type": "bool", "internalType": "bool" }, { "name": "clear", "type": "bool", "internalType": "bool" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "registry", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract FuseRegistry" }], "stateMutability": "view" }, { "type": "function", "name": "removeFuse", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "removePayee", "inputs": [{ "name": "payee", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "revokeApproval", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "to", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setAgent", "inputs": [{ "name": "agent", "type": "address", "internalType": "address" }, { "name": "enabled", "type": "bool", "internalType": "bool" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setApprovalTtl", "inputs": [{ "name": "ttl", "type": "uint32", "internalType": "uint32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setApprovers", "inputs": [{ "name": "seats", "type": "address[3]", "internalType": "address[3]" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setDailyLimits", "inputs": [{ "name": "maxDecisions", "type": "uint32", "internalType": "uint32" }, { "name": "maxBlocked", "type": "uint32", "internalType": "uint32" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setFuseMaxFee", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }, { "name": "maxFee", "type": "uint96", "internalType": "uint96" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setFuseParams", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }, { "name": "params", "type": "tuple", "internalType": "struct Sockets.Params", "components": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "unit", "type": "uint128", "internalType": "uint128" }, { "name": "a", "type": "uint8", "internalType": "uint8" }, { "name": "b", "type": "uint8", "internalType": "uint8" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setPaused", "inputs": [{ "name": "paused_", "type": "bool", "internalType": "bool" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setToken", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "enabled", "type": "bool", "internalType": "bool" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "slotAt", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "tuple", "internalType": "struct FuseboxWallet.Slot", "components": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }, { "name": "processor", "type": "address", "internalType": "address" }, { "name": "circuitId", "type": "uint64", "internalType": "uint64" }, { "name": "socket", "type": "uint32", "internalType": "uint32" }, { "name": "nOut", "type": "uint32", "internalType": "uint32" }, { "name": "nState", "type": "uint32", "internalType": "uint32" }, { "name": "maxFee", "type": "uint96", "internalType": "uint96" }, { "name": "params", "type": "tuple", "internalType": "struct Sockets.Params", "components": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "unit", "type": "uint128", "internalType": "uint128" }, { "name": "a", "type": "uint8", "internalType": "uint8" }, { "name": "b", "type": "uint8", "internalType": "uint8" }] }, { "name": "spentDay", "type": "uint32", "internalType": "uint32" }, { "name": "spent", "type": "uint256", "internalType": "uint256" }, { "name": "state", "type": "bytes", "internalType": "bytes" }] }], "stateMutability": "view" }, { "type": "function", "name": "spentToday", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "tokenEnabled", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "transferOwnership", "inputs": [{ "name": "newOwner", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "unfreeze", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "withdrawFeeBalance", "inputs": [{ "name": "amount", "type": "uint256", "internalType": "uint256" }, { "name": "to", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "AgentSet", "inputs": [{ "name": "agent", "type": "address", "indexed": true, "internalType": "address" }, { "name": "enabled", "type": "bool", "indexed": false, "internalType": "bool" }], "anonymous": false }, { "type": "event", "name": "ApprovalRevoked", "inputs": [{ "name": "intent", "type": "bytes32", "indexed": true, "internalType": "bytes32" }, { "name": "approver", "type": "address", "indexed": true, "internalType": "address" }, { "name": "mask", "type": "uint8", "indexed": false, "internalType": "uint8" }], "anonymous": false }, { "type": "event", "name": "ApprovalTtlSet", "inputs": [{ "name": "ttl", "type": "uint32", "indexed": false, "internalType": "uint32" }], "anonymous": false }, { "type": "event", "name": "Approved", "inputs": [{ "name": "intent", "type": "bytes32", "indexed": true, "internalType": "bytes32" }, { "name": "approver", "type": "address", "indexed": true, "internalType": "address" }, { "name": "mask", "type": "uint8", "indexed": false, "internalType": "uint8" }], "anonymous": false }, { "type": "event", "name": "ApproversSet", "inputs": [{ "name": "approvers", "type": "address[3]", "indexed": false, "internalType": "address[3]" }, { "name": "epoch", "type": "uint64", "indexed": false, "internalType": "uint64" }], "anonymous": false }, { "type": "event", "name": "BreakerSkipped", "inputs": [{ "name": "slot", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "status", "type": "uint8", "indexed": false, "internalType": "uint8" }], "anonymous": false }, { "type": "event", "name": "ControlBeat", "inputs": [{ "name": "slot", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "by", "type": "address", "indexed": true, "internalType": "address" }, { "name": "inputs", "type": "bytes", "indexed": false, "internalType": "bytes" }, { "name": "newState", "type": "bytes", "indexed": false, "internalType": "bytes" }], "anonymous": false }, { "type": "event", "name": "DailyLimitsSet", "inputs": [{ "name": "maxDecisions", "type": "uint32", "indexed": false, "internalType": "uint32" }, { "name": "maxBlocked", "type": "uint32", "indexed": false, "internalType": "uint32" }], "anonymous": false }, { "type": "event", "name": "Decision", "inputs": [{ "name": "decisionId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "agent", "type": "address", "indexed": true, "internalType": "address" }, { "name": "to", "type": "address", "indexed": true, "internalType": "address" }, { "name": "token", "type": "address", "indexed": false, "internalType": "address" }, { "name": "amount", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "allowed", "type": "bool", "indexed": false, "internalType": "bool" }, { "name": "fuseIds", "type": "uint256[]", "indexed": false, "internalType": "uint256[]" }, { "name": "status", "type": "uint8[]", "indexed": false, "internalType": "uint8[]" }, { "name": "inputs", "type": "bytes[]", "indexed": false, "internalType": "bytes[]" }, { "name": "outputs", "type": "bytes[]", "indexed": false, "internalType": "bytes[]" }, { "name": "feePaid", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "intent", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "memo", "type": "string", "indexed": false, "internalType": "string" }], "anonymous": false }, { "type": "event", "name": "Executed", "inputs": [{ "name": "target", "type": "address", "indexed": true, "internalType": "address" }, { "name": "value", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "data", "type": "bytes", "indexed": false, "internalType": "bytes" }], "anonymous": false }, { "type": "event", "name": "FuseAdded", "inputs": [{ "name": "slot", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "params", "type": "tuple", "indexed": false, "internalType": "struct Sockets.Params", "components": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "unit", "type": "uint128", "internalType": "uint128" }, { "name": "a", "type": "uint8", "internalType": "uint8" }, { "name": "b", "type": "uint8", "internalType": "uint8" }] }, { "name": "maxFee", "type": "uint96", "indexed": false, "internalType": "uint96" }], "anonymous": false }, { "type": "event", "name": "FuseBlew", "inputs": [{ "name": "decisionId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "slot", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "status", "type": "uint8", "indexed": false, "internalType": "uint8" }], "anonymous": false }, { "type": "event", "name": "FuseMaxFeeSet", "inputs": [{ "name": "slot", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "maxFee", "type": "uint96", "indexed": false, "internalType": "uint96" }], "anonymous": false }, { "type": "event", "name": "FuseParamsSet", "inputs": [{ "name": "slot", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "params", "type": "tuple", "indexed": false, "internalType": "struct Sockets.Params", "components": [{ "name": "token", "type": "address", "internalType": "address" }, { "name": "unit", "type": "uint128", "internalType": "uint128" }, { "name": "a", "type": "uint8", "internalType": "uint8" }, { "name": "b", "type": "uint8", "internalType": "uint8" }] }], "anonymous": false }, { "type": "event", "name": "FuseRemoved", "inputs": [{ "name": "slot", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "OwnershipTransferStarted", "inputs": [{ "name": "previousOwner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "OwnershipTransferred", "inputs": [{ "name": "previousOwner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "PausedSet", "inputs": [{ "name": "paused", "type": "bool", "indexed": false, "internalType": "bool" }], "anonymous": false }, { "type": "event", "name": "PayeeAdded", "inputs": [{ "name": "payee", "type": "address", "indexed": true, "internalType": "address" }, { "name": "at", "type": "uint64", "indexed": false, "internalType": "uint64" }], "anonymous": false }, { "type": "event", "name": "PayeeRemoved", "inputs": [{ "name": "payee", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "TokenSet", "inputs": [{ "name": "token", "type": "address", "indexed": true, "internalType": "address" }, { "name": "enabled", "type": "bool", "indexed": false, "internalType": "bool" }], "anonymous": false }, { "type": "error", "name": "AgentCannotApprove", "inputs": [{ "name": "who", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "AlreadyListed", "inputs": [] }, { "type": "error", "name": "BadIndex", "inputs": [] }, { "type": "error", "name": "BadParams", "inputs": [{ "name": "socket", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "BadPayee", "inputs": [] }, { "type": "error", "name": "BlockedLimitReached", "inputs": [{ "name": "limit", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "CallFailed", "inputs": [{ "name": "reason", "type": "bytes", "internalType": "bytes" }] }, { "type": "error", "name": "ControlBeatFailed", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }, { "name": "status", "type": "uint8", "internalType": "uint8" }] }, { "type": "error", "name": "DecisionLimitReached", "inputs": [{ "name": "limit", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "DuplicateApprover", "inputs": [] }, { "type": "error", "name": "FeeAboveMax", "inputs": [{ "name": "fee", "type": "uint256", "internalType": "uint256" }, { "name": "maxFee", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "FuseNotListed", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "InsufficientGas", "inputs": [] }, { "type": "error", "name": "IsPaused", "inputs": [] }, { "type": "error", "name": "NativeTransferFailed", "inputs": [] }, { "type": "error", "name": "NoBreaker", "inputs": [] }, { "type": "error", "name": "NoFuses", "inputs": [] }, { "type": "error", "name": "NoOwnerPins", "inputs": [{ "name": "slot", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "NotAgent", "inputs": [] }, { "type": "error", "name": "NotAllowedToFreeze", "inputs": [] }, { "type": "error", "name": "NotApprover", "inputs": [] }, { "type": "error", "name": "NotOwner", "inputs": [] }, { "type": "error", "name": "ReentrancyGuardReentrantCall", "inputs": [] }, { "type": "error", "name": "SafeERC20FailedOperation", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "TokenNotEnabled", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "TooManyFuses", "inputs": [] }, { "type": "error", "name": "UnknownSocket", "inputs": [{ "name": "socket", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "ZeroAddress", "inputs": [] }, { "type": "error", "name": "ZeroAmount", "inputs": [] }];
3
+ export const fuseRegistryAbi = [{ "type": "constructor", "inputs": [{ "name": "feeToken_", "type": "address", "internalType": "contract IERC20" }, { "name": "factory_", "type": "address", "internalType": "contract ITapeoutFactory" }, { "name": "admin", "type": "address", "internalType": "address" }, { "name": "protocolFeeBps_", "type": "uint16", "internalType": "uint16" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "MAX_GATES", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "MAX_PROTOCOL_FEE_BPS", "inputs": [], "outputs": [{ "name": "", "type": "uint16", "internalType": "uint16" }], "stateMutability": "view" }, { "type": "function", "name": "MAX_STATE_BITS", "inputs": [], "outputs": [{ "name": "", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "acceptOwnership", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "beaconOfCodehash", "inputs": [{ "name": "codehash", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "beacon", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "charge", "inputs": [{ "name": "fuseIds", "type": "uint256[]", "internalType": "uint256[]" }, { "name": "maxFees", "type": "uint256[]", "internalType": "uint256[]" }], "outputs": [{ "name": "total", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "claim", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }, { "name": "to", "type": "address", "internalType": "address" }], "outputs": [{ "name": "amount", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "claimProtocol", "inputs": [{ "name": "to", "type": "address", "internalType": "address" }], "outputs": [{ "name": "amount", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "decisions", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }], "stateMutability": "view" }, { "type": "function", "name": "deposit", "inputs": [{ "name": "account", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "received", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "designerOf", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "earned", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "factory", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract ITapeoutFactory" }], "stateMutability": "view" }, { "type": "function", "name": "feeBalance", "inputs": [{ "name": "account", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "feeOf", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "feeToken", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract IERC20" }], "stateMutability": "view" }, { "type": "function", "name": "fuse", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "f", "type": "tuple", "internalType": "struct FuseRegistry.Fuse", "components": [{ "name": "processor", "type": "address", "internalType": "address" }, { "name": "circuitId", "type": "uint64", "internalType": "uint64" }, { "name": "socket", "type": "uint32", "internalType": "uint32" }, { "name": "nIn", "type": "uint32", "internalType": "uint32" }, { "name": "nOut", "type": "uint32", "internalType": "uint32" }, { "name": "nState", "type": "uint32", "internalType": "uint32" }, { "name": "gateCount", "type": "uint32", "internalType": "uint32" }, { "name": "fee", "type": "uint96", "internalType": "uint96" }, { "name": "listed", "type": "bool", "internalType": "bool" }, { "name": "listedAt", "type": "uint64", "internalType": "uint64" }, { "name": "netlistHash", "type": "bytes32", "internalType": "bytes32" }] }], "stateMutability": "view" }, { "type": "function", "name": "fuseCount", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "fuseIdOf", "inputs": [{ "name": "processor", "type": "address", "internalType": "address" }, { "name": "circuitId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "isTrustedProcessor", "inputs": [{ "name": "processor", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "lifetimeEarned", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "list", "inputs": [{ "name": "processor", "type": "address", "internalType": "address" }, { "name": "circuitId", "type": "uint256", "internalType": "uint256" }, { "name": "socket", "type": "uint32", "internalType": "uint32" }, { "name": "netlistHash", "type": "bytes32", "internalType": "bytes32" }, { "name": "fee", "type": "uint96", "internalType": "uint96" }, { "name": "uri", "type": "string", "internalType": "string" }], "outputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "metadataURI", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "string", "internalType": "string" }], "stateMutability": "view" }, { "type": "function", "name": "originalOf", "inputs": [{ "name": "netlistHash", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "owner", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "pendingOwner", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "protocolEarned", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "protocolFeeBps", "inputs": [], "outputs": [{ "name": "", "type": "uint16", "internalType": "uint16" }], "stateMutability": "view" }, { "type": "function", "name": "renounceOwnership", "inputs": [], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setFee", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }, { "name": "fee", "type": "uint96", "internalType": "uint96" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setListed", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }, { "name": "listed_", "type": "bool", "internalType": "bool" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setMetadataURI", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }, { "name": "uri", "type": "string", "internalType": "string" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setProcessorCodehash", "inputs": [{ "name": "codehash", "type": "bytes32", "internalType": "bytes32" }, { "name": "beacon", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setProtocolFee", "inputs": [{ "name": "bps", "type": "uint16", "internalType": "uint16" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "setTrustedImplementation", "inputs": [{ "name": "implementation", "type": "address", "internalType": "address" }, { "name": "trusted", "type": "bool", "internalType": "bool" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "totalOwed", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "transferOwnership", "inputs": [{ "name": "newOwner", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "trustedImplementation", "inputs": [{ "name": "implementation", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "withdraw", "inputs": [{ "name": "amount", "type": "uint256", "internalType": "uint256" }, { "name": "to", "type": "address", "internalType": "address" }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "event", "name": "Charged", "inputs": [{ "name": "payer", "type": "address", "indexed": true, "internalType": "address" }, { "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "fee", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "designerShare", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "Claimed", "inputs": [{ "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "owner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "to", "type": "address", "indexed": false, "internalType": "address" }, { "name": "amount", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "Deposited", "inputs": [{ "name": "account", "type": "address", "indexed": true, "internalType": "address" }, { "name": "from", "type": "address", "indexed": true, "internalType": "address" }, { "name": "amount", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "FeeChanged", "inputs": [{ "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "oldFee", "type": "uint96", "indexed": false, "internalType": "uint96" }, { "name": "newFee", "type": "uint96", "indexed": false, "internalType": "uint96" }], "anonymous": false }, { "type": "event", "name": "FuseListed", "inputs": [{ "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "processor", "type": "address", "indexed": true, "internalType": "address" }, { "name": "circuitId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "designer", "type": "address", "indexed": false, "internalType": "address" }, { "name": "socket", "type": "uint32", "indexed": false, "internalType": "uint32" }, { "name": "gateCount", "type": "uint32", "indexed": false, "internalType": "uint32" }, { "name": "nState", "type": "uint32", "indexed": false, "internalType": "uint32" }, { "name": "fee", "type": "uint96", "indexed": false, "internalType": "uint96" }, { "name": "netlistHash", "type": "bytes32", "indexed": false, "internalType": "bytes32" }, { "name": "metadataURI", "type": "string", "indexed": false, "internalType": "string" }], "anonymous": false }, { "type": "event", "name": "ImplementationTrusted", "inputs": [{ "name": "implementation", "type": "address", "indexed": true, "internalType": "address" }, { "name": "trusted", "type": "bool", "indexed": false, "internalType": "bool" }], "anonymous": false }, { "type": "event", "name": "ListingChanged", "inputs": [{ "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "listed", "type": "bool", "indexed": false, "internalType": "bool" }], "anonymous": false }, { "type": "event", "name": "MetadataChanged", "inputs": [{ "name": "fuseId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "metadataURI", "type": "string", "indexed": false, "internalType": "string" }], "anonymous": false }, { "type": "event", "name": "OwnershipTransferStarted", "inputs": [{ "name": "previousOwner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "OwnershipTransferred", "inputs": [{ "name": "previousOwner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "ProcessorCodehashSet", "inputs": [{ "name": "codehash", "type": "bytes32", "indexed": true, "internalType": "bytes32" }, { "name": "beacon", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "ProtocolClaimed", "inputs": [{ "name": "to", "type": "address", "indexed": true, "internalType": "address" }, { "name": "amount", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "ProtocolFeeSet", "inputs": [{ "name": "bps", "type": "uint16", "indexed": false, "internalType": "uint16" }], "anonymous": false }, { "type": "event", "name": "Withdrawn", "inputs": [{ "name": "account", "type": "address", "indexed": true, "internalType": "address" }, { "name": "to", "type": "address", "indexed": true, "internalType": "address" }, { "name": "amount", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "error", "name": "AlreadyListed", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "BadCircuitId", "inputs": [] }, { "type": "error", "name": "FeeTooHigh", "inputs": [] }, { "type": "error", "name": "InsufficientFeeBalance", "inputs": [{ "name": "balance", "type": "uint256", "internalType": "uint256" }, { "name": "needed", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "LengthMismatch", "inputs": [] }, { "type": "error", "name": "MalformedNetlist", "inputs": [{ "name": "byteOffset", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "NetlistHashMismatch", "inputs": [{ "name": "expected", "type": "bytes32", "internalType": "bytes32" }, { "name": "actual", "type": "bytes32", "internalType": "bytes32" }] }, { "type": "error", "name": "NotCircuitOwner", "inputs": [{ "name": "caller", "type": "address", "internalType": "address" }, { "name": "owner", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "OwnableInvalidOwner", "inputs": [{ "name": "owner", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "OwnableUnauthorizedAccount", "inputs": [{ "name": "account", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "PinoutMismatch", "inputs": [{ "name": "socket", "type": "uint32", "internalType": "uint32" }, { "name": "nIn", "type": "uint32", "internalType": "uint32" }, { "name": "nOut", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "ReentrancyGuardReentrantCall", "inputs": [] }, { "type": "error", "name": "RefNotAllowed", "inputs": [{ "name": "byteOffset", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "SafeERC20FailedOperation", "inputs": [{ "name": "token", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "StateMismatch", "inputs": [{ "name": "socket", "type": "uint32", "internalType": "uint32" }, { "name": "nState", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "TooManyGates", "inputs": [{ "name": "gateCount", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "TooMuchState", "inputs": [{ "name": "nState", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "UnknownFuse", "inputs": [{ "name": "fuseId", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "UnknownSocket", "inputs": [{ "name": "socket", "type": "uint32", "internalType": "uint32" }] }, { "type": "error", "name": "UntrustedProcessor", "inputs": [{ "name": "processor", "type": "address", "internalType": "address" }] }, { "type": "error", "name": "ZeroAddress", "inputs": [] }];
4
+ export const fuseboxFactoryAbi = [{ "type": "constructor", "inputs": [{ "name": "registry_", "type": "address", "internalType": "contract FuseRegistry" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "createWallet", "inputs": [{ "name": "owner", "type": "address", "internalType": "address" }, { "name": "agents", "type": "address[]", "internalType": "address[]" }, { "name": "salt", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "w", "type": "address", "internalType": "contract FuseboxWallet" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "isWallet", "inputs": [{ "name": "", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "registry", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "contract FuseRegistry" }], "stateMutability": "view" }, { "type": "function", "name": "walletAt", "inputs": [{ "name": "i", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "walletCount", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "event", "name": "WalletCreated", "inputs": [{ "name": "wallet", "type": "address", "indexed": true, "internalType": "address" }, { "name": "owner", "type": "address", "indexed": true, "internalType": "address" }, { "name": "creator", "type": "address", "indexed": true, "internalType": "address" }, { "name": "agents", "type": "address[]", "indexed": false, "internalType": "address[]" }], "anonymous": false }];
5
+ export const tapeoutProcessorAbi = [{ "type": "function", "name": "TAPEOUT_FEE", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "circuitInfo", "inputs": [{ "name": "id", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "nIn", "type": "uint32", "internalType": "uint32" }, { "name": "nOut", "type": "uint32", "internalType": "uint32" }, { "name": "nState", "type": "uint32", "internalType": "uint32" }, { "name": "gateCount", "type": "uint32", "internalType": "uint32" }], "stateMutability": "view" }, { "type": "function", "name": "eval", "inputs": [{ "name": "id", "type": "uint256", "internalType": "uint256" }, { "name": "inputs", "type": "bytes", "internalType": "bytes" }], "outputs": [{ "name": "", "type": "bytes", "internalType": "bytes" }], "stateMutability": "view" }, { "type": "function", "name": "factory", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "netlist", "inputs": [{ "name": "id", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "bytes", "internalType": "bytes" }], "stateMutability": "view" }, { "type": "function", "name": "nextId", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "ownerOf", "inputs": [{ "name": "id", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "step", "inputs": [{ "name": "id", "type": "uint256", "internalType": "uint256" }, { "name": "state", "type": "bytes", "internalType": "bytes" }, { "name": "inputs", "type": "bytes", "internalType": "bytes" }], "outputs": [{ "name": "newState", "type": "bytes", "internalType": "bytes" }, { "name": "outputs", "type": "bytes", "internalType": "bytes" }], "stateMutability": "view" }, { "type": "function", "name": "tapeout", "inputs": [{ "name": "nl", "type": "bytes", "internalType": "bytes" }, { "name": "nIn", "type": "uint32", "internalType": "uint32" }, { "name": "nOut", "type": "uint32", "internalType": "uint32" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "payable" }, { "type": "function", "name": "transistors", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "event", "name": "TapedOut", "inputs": [{ "name": "circuitId", "type": "uint256", "indexed": true, "internalType": "uint256" }, { "name": "author", "type": "address", "indexed": true, "internalType": "address" }, { "name": "gateCount", "type": "uint32", "indexed": false, "internalType": "uint32" }, { "name": "nState", "type": "uint32", "indexed": false, "internalType": "uint32" }], "anonymous": false }];
@@ -0,0 +1,142 @@
1
+ /**
2
+ * fusebox-sdk: pay from an AI agent's Fusebox wallet on X Layer, where every payment has to pass logic-circuit
3
+ * "fuses" taped out on TapeOut. Check a payment for free, pay with the agent's key (checked first, so a refusal
4
+ * costs nothing), read the wallet, follow its decisions live, approve or freeze.
5
+ */
6
+ import { type Account, type Address, type Chain, type Hash, type Hex, type PublicClient, type WalletClient } from "viem";
7
+ export { fuseboxWalletAbi, fuseRegistryAbi, fuseboxFactoryAbi, tapeoutProcessorAbi } from "./abi.js";
8
+ /** X Layer mainnet (chain 196). */
9
+ export declare const xLayer: Chain;
10
+ /** Fusebox on X Layer mainnet. Atlas is the public demo wallet. */
11
+ export declare const ADDRESSES: {
12
+ readonly registry: "0x852a278322667BB86A2665a38CbC5Bfd551B20d7";
13
+ readonly factory: "0x192C099a18ed42612b6e74f243f8dF1EE0E3E7a5";
14
+ readonly atlas: "0x0Db0457715a6445D8a65F820d717a6B39Be66800";
15
+ readonly usdt0: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736";
16
+ };
17
+ export type Verdict = "pass" | "blew" | "failed" | "untrusted";
18
+ export interface FuseState {
19
+ slot: number;
20
+ fuseId: number;
21
+ name: string;
22
+ socket: number;
23
+ circuitId: number;
24
+ processor: Address;
25
+ /** the designer's current fee and the most this wallet accepts, in USDT0 per check */
26
+ fee: string;
27
+ maxFee: string;
28
+ /** the owner's two settings, in the socket's units (USDT0 or hours) */
29
+ settings: {
30
+ a: number;
31
+ b: number;
32
+ };
33
+ /** a sequential fuse that would refuse a clean payment right now (for example a tripped Breaker) */
34
+ blown: boolean;
35
+ spentToday: string;
36
+ }
37
+ export interface WalletStatus {
38
+ wallet: Address;
39
+ owner: Address;
40
+ paused: boolean;
41
+ balance: string;
42
+ feeBalance: string;
43
+ decisions: number;
44
+ paid: number;
45
+ stopped: number;
46
+ limits: {
47
+ decisionsPerDay: number;
48
+ blockedPerDay: number;
49
+ };
50
+ fuses: FuseState[];
51
+ }
52
+ export interface CheckResult {
53
+ allowed: boolean;
54
+ to: Address;
55
+ amount: string;
56
+ block: number;
57
+ fuses: {
58
+ name: string;
59
+ verdict: Verdict;
60
+ why: string;
61
+ }[];
62
+ /** one sentence for a person (or an agent) to read */
63
+ summary: string;
64
+ }
65
+ export interface PayResult {
66
+ /** the payment went through */
67
+ paid: boolean;
68
+ /** a transaction was sent (false when the free check already said no) */
69
+ sent: boolean;
70
+ decisionId?: number;
71
+ tx?: Hash;
72
+ txUrl?: string;
73
+ feePaid?: string;
74
+ fuses: {
75
+ name: string;
76
+ verdict: Verdict;
77
+ }[];
78
+ summary: string;
79
+ check?: CheckResult;
80
+ }
81
+ export interface Decision {
82
+ id: number;
83
+ time: number;
84
+ to: Address;
85
+ amount: string;
86
+ paid: boolean;
87
+ fee: string;
88
+ tx?: Hash;
89
+ fuses: {
90
+ name: string;
91
+ verdict: Verdict;
92
+ }[];
93
+ }
94
+ export interface FuseboxOptions {
95
+ /** the Fusebox wallet (default: Atlas, the public demo wallet) */
96
+ wallet?: Address;
97
+ /** X Layer RPC (default https://rpc.xlayer.tech) */
98
+ rpc?: string;
99
+ /** the agent's (or an approver's) key or viem account; without it the client is read-only */
100
+ account?: Account | Hex;
101
+ /** where history() reads the indexed log (default the hosted Fusebox app) */
102
+ api?: string;
103
+ publicClient?: PublicClient;
104
+ walletClient?: WalletClient;
105
+ }
106
+ export declare class FuseboxError extends Error {
107
+ }
108
+ /** A client for one Fusebox wallet. */
109
+ export declare class Fusebox {
110
+ readonly wallet: Address;
111
+ readonly public: PublicClient;
112
+ readonly account: Account | null;
113
+ readonly walletClient: WalletClient | null;
114
+ private readonly api;
115
+ private meta;
116
+ constructor(opts?: FuseboxOptions);
117
+ private get W();
118
+ /** Every fuse on the wallet's line, in order. */
119
+ fuses(): Promise<FuseState[]>;
120
+ /** Balance, prepaid fees, the fuses and whether any is blown, counts and daily budgets. */
121
+ status(): Promise<WalletStatus>;
122
+ /** Dry-run a USDT0 payment against every fuse: free, read-only, nothing moves. */
123
+ check(to: string, amount: string | number): Promise<CheckResult>;
124
+ /**
125
+ * Pay in USDT0 through the fuses with the agent's key. By default it checks first and doesn't send a payment the
126
+ * fuses would refuse (a refused payment is still recorded and its checks are still paid for). Pass
127
+ * { checkFirst: false } to record the attempt anyway.
128
+ */
129
+ pay(to: string, amount: string | number, memo: string, opts?: {
130
+ checkFirst?: boolean;
131
+ }): Promise<PayResult>;
132
+ /** As an approver: sign off this exact payment (payee and amount) for Two of Three. */
133
+ approve(to: string, amount: string | number): Promise<Hash>;
134
+ /** As the agent, an approver or the owner: stop every payment now (only the owner can undo it). */
135
+ freeze(): Promise<Hash>;
136
+ /** The wallet's decisions, oldest first, from Fusebox's indexed log (X Layer RPCs cap log ranges). */
137
+ history(): Promise<Decision[]>;
138
+ /** Call `onDecision` for every new decision as it lands on X Layer. Returns a function that stops watching. */
139
+ watch(onDecision: (d: Decision) => void, opts?: {
140
+ pollingInterval?: number;
141
+ }): () => void;
142
+ }
package/dist/index.js ADDED
@@ -0,0 +1,237 @@
1
+ /**
2
+ * fusebox-sdk: pay from an AI agent's Fusebox wallet on X Layer, where every payment has to pass logic-circuit
3
+ * "fuses" taped out on TapeOut. Check a payment for free, pay with the agent's key (checked first, so a refusal
4
+ * costs nothing), read the wallet, follow its decisions live, approve or freeze.
5
+ */
6
+ import { createPublicClient, createWalletClient, decodeEventLog, defineChain, formatUnits, getAddress, http, isAddress, parseUnits, } from "viem";
7
+ import { privateKeyToAccount } from "viem/accounts";
8
+ import { fuseboxWalletAbi, fuseRegistryAbi, tapeoutProcessorAbi } from "./abi.js";
9
+ export { fuseboxWalletAbi, fuseRegistryAbi, fuseboxFactoryAbi, tapeoutProcessorAbi } from "./abi.js";
10
+ /** X Layer mainnet (chain 196). */
11
+ export const xLayer = defineChain({
12
+ id: 196, name: "X Layer", nativeCurrency: { name: "OKB", symbol: "OKB", decimals: 18 },
13
+ rpcUrls: { default: { http: ["https://rpc.xlayer.tech"] } },
14
+ blockExplorers: { default: { name: "OKLink", url: "https://www.oklink.com/xlayer" } },
15
+ contracts: { multicall3: { address: "0xcA11bde05977b3631167028862bE2a173976CA11" } },
16
+ });
17
+ /** Fusebox on X Layer mainnet. Atlas is the public demo wallet. */
18
+ export const ADDRESSES = {
19
+ registry: "0x852a278322667BB86A2665a38CbC5Bfd551B20d7",
20
+ factory: "0x192C099a18ed42612b6e74f243f8dF1EE0E3E7a5",
21
+ atlas: "0x0Db0457715a6445D8a65F820d717a6B39Be66800",
22
+ usdt0: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
23
+ };
24
+ const EXPLORER = "https://www.oklink.com/xlayer";
25
+ const SHIPPED = new Set([1, 2, 3, 4]); // the four fuses Fusebox shipped; other designs describe themselves in metadata
26
+ const SOCKET_NAME = { 1: "Daily Cap", 2: "Payee Guard", 3: "Breaker", 4: "Two of Three" };
27
+ const STATUS = ["pass", "blew", "failed", "untrusted"];
28
+ const erc20 = [{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "a", type: "address" }], outputs: [{ type: "uint256" }] }];
29
+ const usd = (v) => formatUnits(v, 6);
30
+ function decodeMeta(uri) {
31
+ const m = /^data:application\/json(;charset=utf-8)?(;base64)?,(.*)$/is.exec(uri.trim());
32
+ if (!m)
33
+ return null;
34
+ try {
35
+ const raw = m[2] ? (typeof atob === "function" ? new TextDecoder().decode(Uint8Array.from(atob(m[3]), (c) => c.charCodeAt(0))) : Buffer.from(m[3], "base64").toString("utf8")) : decodeURIComponent(m[3]);
36
+ const j = JSON.parse(raw);
37
+ const s = (v) => (typeof v === "string" ? v.slice(0, 200) : undefined);
38
+ return { name: s(j.name), summary: s(j.summary), rule: s(j.rule) };
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ }
44
+ export class FuseboxError extends Error {
45
+ }
46
+ /** A client for one Fusebox wallet. */
47
+ export class Fusebox {
48
+ wallet;
49
+ public;
50
+ account;
51
+ walletClient;
52
+ api;
53
+ meta = new Map();
54
+ constructor(opts = {}) {
55
+ this.wallet = getAddress(opts.wallet ?? ADDRESSES.atlas);
56
+ const rpc = opts.rpc ?? "https://rpc.xlayer.tech";
57
+ const chain = { ...xLayer, rpcUrls: { default: { http: [rpc] } } };
58
+ this.public = opts.publicClient ?? createPublicClient({ chain, transport: http(rpc), batch: { multicall: true } });
59
+ this.account = typeof opts.account === "string" ? privateKeyToAccount(opts.account) : opts.account ?? null;
60
+ this.walletClient = opts.walletClient ?? (this.account ? createWalletClient({ chain, transport: http(rpc), account: this.account }) : null);
61
+ this.api = (opts.api ?? "https://fusebox-xlayer.vercel.app").replace(/\/$/, "");
62
+ }
63
+ get W() { return { address: this.wallet, abi: fuseboxWalletAbi }; }
64
+ /** Every fuse on the wallet's line, in order. */
65
+ async fuses() {
66
+ const n = Number(await this.public.readContract({ ...this.W, functionName: "fuseCount" }));
67
+ const registry = await this.public.readContract({ ...this.W, functionName: "registry" });
68
+ return Promise.all(Array.from({ length: n }, async (_, i) => {
69
+ const s = await this.public.readContract({ ...this.W, functionName: "slotAt", args: [BigInt(i)] });
70
+ const id = Number(s.fuseId);
71
+ const [f, spent, uri, blown] = await Promise.all([
72
+ this.public.readContract({ address: registry, abi: fuseRegistryAbi, functionName: "fuse", args: [s.fuseId] }),
73
+ this.public.readContract({ ...this.W, functionName: "spentToday", args: [BigInt(i)] }),
74
+ this.meta.has(id) ? Promise.resolve(null) : this.public.readContract({ address: registry, abi: fuseRegistryAbi, functionName: "metadataURI", args: [s.fuseId] }).catch(() => ""),
75
+ s.nState > 0
76
+ ? this.public.readContract({ address: s.processor, abi: tapeoutProcessorAbi, functionName: "step", args: [s.circuitId, s.state, "0x04"] }).then(([, out]) => (Number(BigInt(out === "0x" ? "0x0" : out)) & 1) === 0).catch(() => s.state !== "0x" && BigInt(s.state) !== 0n)
77
+ : Promise.resolve(false),
78
+ ]);
79
+ if (!this.meta.has(id))
80
+ this.meta.set(id, uri ? decodeMeta(uri) : null);
81
+ const meta = this.meta.get(id);
82
+ return {
83
+ slot: i, fuseId: id, name: (SHIPPED.has(id) ? SOCKET_NAME[Number(s.socket)] : meta?.name) ?? SOCKET_NAME[Number(s.socket)] ?? `Fuse ${id}`,
84
+ socket: Number(s.socket), circuitId: Number(s.circuitId), processor: s.processor, fee: usd(f.fee), maxFee: usd(s.maxFee),
85
+ settings: { a: Number(s.params.a), b: Number(s.params.b) }, blown, spentToday: usd(spent),
86
+ };
87
+ }));
88
+ }
89
+ /** Balance, prepaid fees, the fuses and whether any is blown, counts and daily budgets. */
90
+ async status() {
91
+ const registry = await this.public.readContract({ ...this.W, functionName: "registry" });
92
+ const [owner, paused, bal, fee, n, ok, no, maxD, maxB, fuses] = await Promise.all([
93
+ this.public.readContract({ ...this.W, functionName: "owner" }),
94
+ this.public.readContract({ ...this.W, functionName: "paused" }),
95
+ this.public.readContract({ address: ADDRESSES.usdt0, abi: erc20, functionName: "balanceOf", args: [this.wallet] }),
96
+ this.public.readContract({ address: registry, abi: fuseRegistryAbi, functionName: "feeBalance", args: [this.wallet] }),
97
+ this.public.readContract({ ...this.W, functionName: "decisionCount" }),
98
+ this.public.readContract({ ...this.W, functionName: "allowedCount" }),
99
+ this.public.readContract({ ...this.W, functionName: "blockedCount" }),
100
+ this.public.readContract({ ...this.W, functionName: "maxDecisionsPerDay" }),
101
+ this.public.readContract({ ...this.W, functionName: "maxBlockedPerDay" }),
102
+ this.fuses(),
103
+ ]);
104
+ return { wallet: this.wallet, owner, paused, balance: usd(bal), feeBalance: usd(fee), decisions: Number(n), paid: Number(ok), stopped: Number(no), limits: { decisionsPerDay: Number(maxD), blockedPerDay: Number(maxB) }, fuses };
105
+ }
106
+ /** Dry-run a USDT0 payment against every fuse: free, read-only, nothing moves. */
107
+ async check(to, amount) {
108
+ const payee = parseTo(to), amt = parseAmount(amount);
109
+ const [[allowed, status], fuses, block, since, mask] = await Promise.all([
110
+ this.public.readContract({ ...this.W, functionName: "check", args: [ADDRESSES.usdt0, payee, amt] }),
111
+ this.fuses(),
112
+ this.public.getBlockNumber(),
113
+ this.public.readContract({ ...this.W, functionName: "payeeAddedAt", args: [payee] }),
114
+ this.public.readContract({ ...this.W, functionName: "approvalMaskOf", args: [ADDRESSES.usdt0, payee, amt] }),
115
+ ]);
116
+ const a = Number(usd(amt)), hours = since ? (Date.now() / 1000 - Number(since)) / 3600 : 0;
117
+ const approvals = [0, 1, 2].filter((b) => (Number(mask) >> b) & 1).length;
118
+ const verdicts = fuses.map((f, i) => {
119
+ const v = STATUS[status[i]] ?? "failed", pass = v === "pass", { a: p, b: q } = f.settings;
120
+ let why;
121
+ if (v === "failed")
122
+ why = "the circuit call failed, so the fuse fails closed";
123
+ else if (v === "untrusted")
124
+ why = "TapeOut's processor code changed and isn't attested, so the fuse fails closed";
125
+ else if (!SHIPPED.has(f.fuseId)) {
126
+ const m = this.meta.get(f.fuseId);
127
+ why = pass ? "holds" : `refused under its rule${m?.rule ? ` (${m.rule})` : m?.summary ? `: ${m.summary}` : ""}`;
128
+ }
129
+ else if (f.socket === 1)
130
+ why = pass ? `within today's cap (${Math.max(0, p - Number(f.spentToday))} of ${p} USDT0 left)` : `${a} USDT0 would pass today's ${p} USDT0 cap (${f.spentToday} spent)`;
131
+ else if (f.socket === 2)
132
+ why = pass ? (since && hours >= p ? "a saved payee, past its cooling-off" : `saved ${hours.toFixed(1)} h ago and within the ${q} USDT0 trial`) : !since ? "not a saved payee" : `saved ${hours.toFixed(1)} h ago: until ${p} h have passed it can receive at most ${q} USDT0`;
133
+ else if (f.socket === 3)
134
+ why = f.blown ? "already blown; nothing pays until the owner resets it" : pass ? "not tripped" : "a payment to a stranger trips it, and it stays blown until the owner resets it";
135
+ else
136
+ why = pass ? (a > p ? `over ${p} USDT0 and approved by ${approvals} of 3` : `under the ${p} USDT0 approval threshold`) : `over ${p} USDT0: needs two of three approvers, has ${approvals}`;
137
+ return { name: f.name, verdict: v, why };
138
+ });
139
+ const no = verdicts.filter((x) => x.verdict !== "pass");
140
+ const summary = allowed ? `Every fuse holds: the wallet would pay ${a} USDT0 to ${payee}.` : `Stopped: ${no.map((x) => `${x.name} (${x.why})`).join("; ")}. Nothing would move.`;
141
+ return { allowed, to: payee, amount: String(a), block: Number(block), fuses: verdicts, summary };
142
+ }
143
+ /**
144
+ * Pay in USDT0 through the fuses with the agent's key. By default it checks first and doesn't send a payment the
145
+ * fuses would refuse (a refused payment is still recorded and its checks are still paid for). Pass
146
+ * { checkFirst: false } to record the attempt anyway.
147
+ */
148
+ async pay(to, amount, memo, opts = {}) {
149
+ if (!this.walletClient || !this.account)
150
+ throw new FuseboxError("Read-only client: pass the agent's key as `account` to pay.");
151
+ const payee = parseTo(to), amt = parseAmount(amount);
152
+ if (memo.length > 200)
153
+ throw new FuseboxError("Keep the memo to one line (200 characters).");
154
+ if (!(await this.public.readContract({ ...this.W, functionName: "isAgent", args: [this.account.address] })))
155
+ throw new FuseboxError(`${this.account.address} isn't an agent of ${this.wallet}.`);
156
+ if (opts.checkFirst !== false) {
157
+ const c = await this.check(payee, usd(amt));
158
+ if (!c.allowed)
159
+ return { paid: false, sent: false, fuses: c.fuses.map(({ name, verdict }) => ({ name, verdict })), summary: `Not sent. ${c.summary}`, check: c };
160
+ }
161
+ const args = [ADDRESSES.usdt0, payee, amt, memo];
162
+ const gas = await this.public.estimateContractGas({ ...this.W, functionName: "pay", args, account: this.account }).then((g) => (g * 13n) / 10n).catch(() => 3000000n);
163
+ const hash = await this.walletClient.writeContract({ ...this.W, functionName: "pay", args, gas, account: this.account, chain: this.walletClient.chain ?? xLayer });
164
+ const r = await this.public.waitForTransactionReceipt({ hash, timeout: 120_000 });
165
+ if (r.status !== "success")
166
+ throw new FuseboxError(`The transaction reverted: ${EXPLORER}/tx/${hash}`);
167
+ let d;
168
+ for (const l of r.logs) {
169
+ if (l.address.toLowerCase() !== this.wallet.toLowerCase())
170
+ continue;
171
+ try {
172
+ const ev = decodeEventLog({ abi: fuseboxWalletAbi, data: l.data, topics: l.topics });
173
+ if (ev.eventName === "Decision")
174
+ d = ev.args;
175
+ }
176
+ catch { /* another event */ }
177
+ }
178
+ if (!d)
179
+ throw new FuseboxError(`No decision in the receipt: ${EXPLORER}/tx/${hash}`);
180
+ const names = (await this.fuses()).map((f) => f.name);
181
+ const fuses = d.status.map((s, i) => ({ name: names[i] ?? `Fuse ${i + 1}`, verdict: STATUS[s] ?? "failed" }));
182
+ const blew = fuses.filter((f) => f.verdict !== "pass").map((f) => f.name);
183
+ return {
184
+ paid: d.allowed, sent: true, decisionId: Number(d.decisionId), tx: hash, txUrl: `${EXPLORER}/tx/${hash}`, feePaid: usd(d.feePaid), fuses,
185
+ summary: d.allowed ? `Paid ${usd(amt)} USDT0 to ${payee} (decision #${d.decisionId}).` : `Stopped by ${blew.join(", ")}: nothing moved (decision #${d.decisionId}).`,
186
+ };
187
+ }
188
+ /** As an approver: sign off this exact payment (payee and amount) for Two of Three. */
189
+ async approve(to, amount) {
190
+ if (!this.walletClient || !this.account)
191
+ throw new FuseboxError("Pass the approver's key as `account` to approve.");
192
+ const hash = await this.walletClient.writeContract({ ...this.W, functionName: "approvePayment", args: [ADDRESSES.usdt0, parseTo(to), parseAmount(amount)], account: this.account, chain: this.walletClient.chain ?? xLayer });
193
+ await this.public.waitForTransactionReceipt({ hash });
194
+ return hash;
195
+ }
196
+ /** As the agent, an approver or the owner: stop every payment now (only the owner can undo it). */
197
+ async freeze() {
198
+ if (!this.walletClient || !this.account)
199
+ throw new FuseboxError("Pass a key as `account` to freeze.");
200
+ const hash = await this.walletClient.writeContract({ ...this.W, functionName: "freeze", account: this.account, chain: this.walletClient.chain ?? xLayer });
201
+ await this.public.waitForTransactionReceipt({ hash });
202
+ return hash;
203
+ }
204
+ /** The wallet's decisions, oldest first, from Fusebox's indexed log (X Layer RPCs cap log ranges). */
205
+ async history() {
206
+ const r = await fetch(`${this.api}/api/wallet/${this.wallet}/history`);
207
+ if (!r.ok)
208
+ throw new FuseboxError(`History unavailable (${r.status}).`);
209
+ const j = (await r.json());
210
+ return j.rows.map((x) => ({ id: x.id, time: x.t, to: x.to, amount: String(x.a), paid: x.ok, fee: String(x.f), fuses: x.s.map((s, i) => ({ name: x.s.length === j.names.length ? j.names[i] : `Fuse ${i + 1}`, verdict: STATUS[s] ?? "failed" })) }));
211
+ }
212
+ /** Call `onDecision` for every new decision as it lands on X Layer. Returns a function that stops watching. */
213
+ watch(onDecision, opts = {}) {
214
+ let names = [];
215
+ void this.fuses().then((f) => { names = f.map((x) => x.name); }).catch(() => { });
216
+ return this.public.watchContractEvent({
217
+ address: this.wallet, abi: fuseboxWalletAbi, eventName: "Decision", poll: true, pollingInterval: opts.pollingInterval ?? 4000,
218
+ onLogs: (logs) => {
219
+ for (const l of logs) {
220
+ const a = l.args;
221
+ onDecision({ id: Number(a.decisionId), time: Math.floor(Date.now() / 1000), to: a.to, amount: usd(a.amount), paid: a.allowed, fee: usd(a.feePaid), tx: l.transactionHash ?? undefined, fuses: a.status.map((s, i) => ({ name: names[i] ?? `Fuse ${i + 1}`, verdict: STATUS[s] ?? "failed" })) });
222
+ }
223
+ },
224
+ });
225
+ }
226
+ }
227
+ function parseTo(to) {
228
+ if (!isAddress(to, { strict: false }))
229
+ throw new FuseboxError(`"${to}" isn't a valid 0x address.`);
230
+ return getAddress(to.toLowerCase());
231
+ }
232
+ function parseAmount(a) {
233
+ const s = String(a);
234
+ if (!/^\d{1,9}(\.\d{1,6})?$/.test(s) || Number(s) <= 0)
235
+ throw new FuseboxError(`"${s}" isn't an amount above 0 with up to 6 decimals.`);
236
+ return parseUnits(s, 6);
237
+ }
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "fusebox-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "TypeScript client for Fusebox wallets on X Layer: AI-agent payments that must pass logic-circuit fuses taped out on TapeOut. Check for free, pay (checked first), approve, freeze, watch decisions.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
9
+ "files": ["dist", "README.md"],
10
+ "sideEffects": false,
11
+ "engines": { "node": ">=20" },
12
+ "license": "MIT",
13
+ "repository": { "type": "git", "url": "https://github.com/0xdopewilly/fusebox", "directory": "sdk" },
14
+ "homepage": "https://fusebox-xlayer.vercel.app/docs",
15
+ "keywords": ["x-layer", "tapeout", "ai-agents", "agent-wallet", "payments", "fusebox", "viem"],
16
+ "scripts": {
17
+ "build": "tsc -p .",
18
+ "typecheck": "tsc -p . --noEmit",
19
+ "test": "node --test test/*.test.mjs",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "peerDependencies": { "viem": "^2.30.0" },
23
+ "devDependencies": { "typescript": "5.9.3", "viem": "2.57.12", "@types/node": "24.19.2" }
24
+ }