fusebox-sdk 0.0.0-stage → 0.2.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,164 @@
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
+ /** set when an approval fuse is what said no: where the wallet's approvers sign this exact payment */
58
+ approvalUrl?: string;
59
+ fuses: {
60
+ name: string;
61
+ verdict: Verdict;
62
+ why: string;
63
+ }[];
64
+ /** one sentence for a person (or an agent) to read */
65
+ summary: string;
66
+ }
67
+ export interface PayResult {
68
+ /** the payment went through */
69
+ paid: boolean;
70
+ /** a transaction was sent (false when the free check already said no) */
71
+ sent: boolean;
72
+ decisionId?: number;
73
+ tx?: Hash;
74
+ txUrl?: string;
75
+ feePaid?: string;
76
+ fuses: {
77
+ name: string;
78
+ verdict: Verdict;
79
+ }[];
80
+ summary: string;
81
+ check?: CheckResult;
82
+ /** the payment needs approvers' signatures before a retry can pass */
83
+ needsApproval?: {
84
+ url: string;
85
+ };
86
+ }
87
+ /** A payment waiting on an approver (from pending()). */
88
+ export interface PendingApproval {
89
+ wallet: Address;
90
+ to: Address;
91
+ amount: string;
92
+ memo: string;
93
+ attempts: number;
94
+ last: number;
95
+ seats: Address[];
96
+ mySeat: number;
97
+ signed: number;
98
+ threshold: number | null;
99
+ url: string;
100
+ }
101
+ export interface Decision {
102
+ id: number;
103
+ time: number;
104
+ to: Address;
105
+ amount: string;
106
+ paid: boolean;
107
+ fee: string;
108
+ tx?: Hash;
109
+ fuses: {
110
+ name: string;
111
+ verdict: Verdict;
112
+ }[];
113
+ }
114
+ export interface FuseboxOptions {
115
+ /** the Fusebox wallet (default: Atlas, the public demo wallet) */
116
+ wallet?: Address;
117
+ /** X Layer RPC (default https://rpc.xlayer.tech) */
118
+ rpc?: string;
119
+ /** the agent's (or an approver's) key or viem account; without it the client is read-only */
120
+ account?: Account | Hex;
121
+ /** where history() reads the indexed log (default the hosted Fusebox app) */
122
+ api?: string;
123
+ publicClient?: PublicClient;
124
+ walletClient?: WalletClient;
125
+ }
126
+ export declare class FuseboxError extends Error {
127
+ }
128
+ /** A client for one Fusebox wallet. */
129
+ export declare class Fusebox {
130
+ readonly wallet: Address;
131
+ readonly public: PublicClient;
132
+ readonly account: Account | null;
133
+ readonly walletClient: WalletClient | null;
134
+ private readonly api;
135
+ private meta;
136
+ constructor(opts?: FuseboxOptions);
137
+ private get W();
138
+ /** Every fuse on the wallet's line, in order. */
139
+ fuses(): Promise<FuseState[]>;
140
+ /** Balance, prepaid fees, the fuses and whether any is blown, counts and daily budgets. */
141
+ status(): Promise<WalletStatus>;
142
+ /** Dry-run a USDT0 payment against every fuse: free, read-only, nothing moves. */
143
+ check(to: string, amount: string | number): Promise<CheckResult>;
144
+ /**
145
+ * Pay in USDT0 through the fuses with the agent's key. By default it checks first and doesn't send a payment the
146
+ * fuses would refuse (a refused payment is still recorded and its checks are still paid for). Pass
147
+ * { checkFirst: false } to record the attempt anyway.
148
+ */
149
+ pay(to: string, amount: string | number, memo: string, opts?: {
150
+ checkFirst?: boolean;
151
+ }): Promise<PayResult>;
152
+ /** As an approver: sign off this exact payment (payee and amount) for Two of Three. */
153
+ approve(to: string, amount: string | number): Promise<Hash>;
154
+ /** As the agent, an approver or the owner: stop every payment now (only the owner can undo it). */
155
+ freeze(): Promise<Hash>;
156
+ /** Payments waiting on `approver`'s signature, across every Fusebox wallet where they hold a seat. */
157
+ pending(approver: string): Promise<PendingApproval[]>;
158
+ /** The wallet's decisions, oldest first, from Fusebox's indexed log (X Layer RPCs cap log ranges). */
159
+ history(): Promise<Decision[]>;
160
+ /** Call `onDecision` for every new decision as it lands on X Layer. Returns a function that stops watching. */
161
+ watch(onDecision: (d: Decision) => void, opts?: {
162
+ pollingInterval?: number;
163
+ }): () => void;
164
+ }
package/dist/index.js ADDED
@@ -0,0 +1,256 @@
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
+ // when an approval fuse (socket 4) is among the no's, point at the page where approvers sign this exact payment
141
+ const approvalUrl = !allowed && fuses.some((f, i) => f.socket === 4 && verdicts[i].verdict === "blew") ? `${this.api}/app/approve?wallet=${this.wallet}&to=${payee}&amount=${a}` : undefined;
142
+ 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.${approvalUrl && no.length === 1 ? ` Two of the wallet's approvers can sign it at ${approvalUrl}; retry once they have.` : ""}`;
143
+ return { allowed, to: payee, amount: String(a), block: Number(block), fuses: verdicts, summary, approvalUrl };
144
+ }
145
+ /**
146
+ * Pay in USDT0 through the fuses with the agent's key. By default it checks first and doesn't send a payment the
147
+ * fuses would refuse (a refused payment is still recorded and its checks are still paid for). Pass
148
+ * { checkFirst: false } to record the attempt anyway.
149
+ */
150
+ async pay(to, amount, memo, opts = {}) {
151
+ if (!this.walletClient || !this.account)
152
+ throw new FuseboxError("Read-only client: pass the agent's key as `account` to pay.");
153
+ const payee = parseTo(to), amt = parseAmount(amount);
154
+ if (memo.length > 200)
155
+ throw new FuseboxError("Keep the memo to one line (200 characters).");
156
+ if (!(await this.public.readContract({ ...this.W, functionName: "isAgent", args: [this.account.address] })))
157
+ throw new FuseboxError(`${this.account.address} isn't an agent of ${this.wallet}.`);
158
+ if (opts.checkFirst !== false) {
159
+ const c = await this.check(payee, usd(amt));
160
+ // needsApproval only when signatures alone would let the retry through
161
+ const onlyApproval = !!c.approvalUrl && c.fuses.filter((f) => f.verdict !== "pass").length === 1;
162
+ if (!c.allowed)
163
+ return { paid: false, sent: false, fuses: c.fuses.map(({ name, verdict }) => ({ name, verdict })), summary: `Not sent. ${c.summary}`, check: c, needsApproval: onlyApproval ? { url: c.approvalUrl } : undefined };
164
+ }
165
+ // a decision is charged up front from the prepaid fee balance: say so plainly instead of sending a doomed tx
166
+ const [line, registry] = await Promise.all([this.fuses(), this.public.readContract({ ...this.W, functionName: "registry" })]);
167
+ const per = line.reduce((t, f) => t + Math.min(Number(f.fee), Number(f.maxFee)), 0);
168
+ const have = Number(usd(await this.public.readContract({ address: registry, abi: fuseRegistryAbi, functionName: "feeBalance", args: [this.wallet] })));
169
+ if (have + 1e-9 < per)
170
+ throw new FuseboxError(`The wallet's prepaid fee balance (${have} USDT0) can't cover one decision (${per.toFixed(6)} USDT0): the owner needs to top it up before the agent can pay.`);
171
+ const args = [ADDRESSES.usdt0, payee, amt, memo];
172
+ const gas = await this.public.estimateContractGas({ ...this.W, functionName: "pay", args, account: this.account }).then((g) => (g * 13n) / 10n).catch(() => 3000000n);
173
+ const hash = await this.walletClient.writeContract({ ...this.W, functionName: "pay", args, gas, account: this.account, chain: this.walletClient.chain ?? xLayer });
174
+ const r = await this.public.waitForTransactionReceipt({ hash, timeout: 120_000 });
175
+ if (r.status !== "success")
176
+ throw new FuseboxError(`The transaction reverted: ${EXPLORER}/tx/${hash}`);
177
+ let d;
178
+ for (const l of r.logs) {
179
+ if (l.address.toLowerCase() !== this.wallet.toLowerCase())
180
+ continue;
181
+ try {
182
+ const ev = decodeEventLog({ abi: fuseboxWalletAbi, data: l.data, topics: l.topics });
183
+ if (ev.eventName === "Decision")
184
+ d = ev.args;
185
+ }
186
+ catch { /* another event */ }
187
+ }
188
+ if (!d)
189
+ throw new FuseboxError(`No decision in the receipt: ${EXPLORER}/tx/${hash}`);
190
+ const names = (await this.fuses()).map((f) => f.name);
191
+ const fuses = d.status.map((s, i) => ({ name: names[i] ?? `Fuse ${i + 1}`, verdict: STATUS[s] ?? "failed" }));
192
+ const blew = fuses.filter((f) => f.verdict !== "pass").map((f) => f.name);
193
+ return {
194
+ paid: d.allowed, sent: true, decisionId: Number(d.decisionId), tx: hash, txUrl: `${EXPLORER}/tx/${hash}`, feePaid: usd(d.feePaid), fuses,
195
+ summary: d.allowed ? `Paid ${usd(amt)} USDT0 to ${payee} (decision #${d.decisionId}).` : `Stopped by ${blew.join(", ")}: nothing moved (decision #${d.decisionId}).`,
196
+ };
197
+ }
198
+ /** As an approver: sign off this exact payment (payee and amount) for Two of Three. */
199
+ async approve(to, amount) {
200
+ if (!this.walletClient || !this.account)
201
+ throw new FuseboxError("Pass the approver's key as `account` to approve.");
202
+ 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 });
203
+ await this.public.waitForTransactionReceipt({ hash });
204
+ return hash;
205
+ }
206
+ /** As the agent, an approver or the owner: stop every payment now (only the owner can undo it). */
207
+ async freeze() {
208
+ if (!this.walletClient || !this.account)
209
+ throw new FuseboxError("Pass a key as `account` to freeze.");
210
+ const hash = await this.walletClient.writeContract({ ...this.W, functionName: "freeze", account: this.account, chain: this.walletClient.chain ?? xLayer });
211
+ await this.public.waitForTransactionReceipt({ hash });
212
+ return hash;
213
+ }
214
+ /** Payments waiting on `approver`'s signature, across every Fusebox wallet where they hold a seat. */
215
+ async pending(approver) {
216
+ const a = parseTo(approver);
217
+ const r = await fetch(`${this.api}/api/approvals?approver=${a}`);
218
+ if (!r.ok)
219
+ throw new FuseboxError(`Approvals unavailable (${r.status}).`);
220
+ const j = (await r.json());
221
+ return j.open.map(({ mask, ...x }) => ({ ...x, signed: [0, 1, 2].filter((i) => (mask >> i) & 1).length, url: `${this.api}/app/approve?wallet=${x.wallet}&to=${x.to}&amount=${x.amount}` }));
222
+ }
223
+ /** The wallet's decisions, oldest first, from Fusebox's indexed log (X Layer RPCs cap log ranges). */
224
+ async history() {
225
+ const r = await fetch(`${this.api}/api/wallet/${this.wallet}/history`);
226
+ if (!r.ok)
227
+ throw new FuseboxError(`History unavailable (${r.status}).`);
228
+ const j = (await r.json());
229
+ 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" })) }));
230
+ }
231
+ /** Call `onDecision` for every new decision as it lands on X Layer. Returns a function that stops watching. */
232
+ watch(onDecision, opts = {}) {
233
+ let names = [];
234
+ void this.fuses().then((f) => { names = f.map((x) => x.name); }).catch(() => { });
235
+ return this.public.watchContractEvent({
236
+ address: this.wallet, abi: fuseboxWalletAbi, eventName: "Decision", poll: true, pollingInterval: opts.pollingInterval ?? 4000,
237
+ onLogs: (logs) => {
238
+ for (const l of logs) {
239
+ const a = l.args;
240
+ 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" })) });
241
+ }
242
+ },
243
+ });
244
+ }
245
+ }
246
+ function parseTo(to) {
247
+ if (!isAddress(to, { strict: false }))
248
+ throw new FuseboxError(`"${to}" isn't a valid 0x address.`);
249
+ return getAddress(to.toLowerCase());
250
+ }
251
+ function parseAmount(a) {
252
+ const s = String(a);
253
+ if (!/^\d{1,9}(\.\d{1,6})?$/.test(s) || Number(s) <= 0)
254
+ throw new FuseboxError(`"${s}" isn't an amount above 0 with up to 6 decimals.`);
255
+ return parseUnits(s, 6);
256
+ }