multicoyn-sdk 0.1.4 → 0.1.6

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.
@@ -1,4 +1,4 @@
1
- import { s as b, t as x, f as F, A as I, d as C, g as M, a as E, b as D, e as w, c as G, h as A, i as T, I as H, j as m, k as v, l as R, m as k, B as y, n as N, o as P, p as j, q as B, r as U, H as L, u as _ } from "./index-CzsOkJ6p.js";
1
+ import { s as b, t as x, f as F, A as I, d as C, g as M, a as E, b as D, e as w, c as G, h as A, i as T, I as H, j as m, k as v, l as R, m as k, B as y, n as N, o as P, p as j, q as B, r as U, H as L, u as _ } from "./index-D8LL3fRQ.js";
2
2
  function J(e) {
3
3
  const { abi: s, data: a } = e, r = b(a, 0, 4), t = s.find((n) => n.type === "function" && r === x(F(n)));
4
4
  if (!t)
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CZikbn9q.cjs");function k(r){const{abi:n,data:a}=r,o=e.slice(a,0,4),t=n.find(s=>s.type==="function"&&o===e.toFunctionSelector(e.formatAbiItem(s)));if(!t)throw new e.AbiFunctionSignatureNotFoundError(o,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:t.name,args:"inputs"in t&&t.inputs&&t.inputs.length>0?e.decodeAbiParameters(t.inputs,e.slice(a,4)):void 0}}const h="/docs/contract/encodeErrorResult";function y(r){const{abi:n,errorName:a,args:o}=r;let t=n[0];if(a){const f=e.getAbiItem({abi:n,args:o,name:a});if(!f)throw new e.AbiErrorNotFoundError(a,{docsPath:h});t=f}if(t.type!=="error")throw new e.AbiErrorNotFoundError(void 0,{docsPath:h});const s=e.formatAbiItem(t),c=e.toFunctionSelector(s);let i="0x";if(o&&o.length>0){if(!t.inputs)throw new e.AbiErrorInputsNotFoundError(t.name,{docsPath:h});i=e.encodeAbiParameters(t.inputs,o)}return e.concatHex([c,i])}const m="/docs/contract/encodeFunctionResult";function L(r){const{abi:n,functionName:a,result:o}=r;let t=n[0];if(a){const c=e.getAbiItem({abi:n,name:a});if(!c)throw new e.AbiFunctionNotFoundError(a,{docsPath:m});t=c}if(t.type!=="function")throw new e.AbiFunctionNotFoundError(void 0,{docsPath:m});if(!t.outputs)throw new e.AbiFunctionOutputsNotFoundError(t.name,{docsPath:m});const s=(()=>{if(t.outputs.length===0)return[];if(t.outputs.length===1)return[o];if(Array.isArray(o))return o;throw new e.InvalidArrayError(o)})();return e.encodeAbiParameters(t.outputs,s)}const b="x-batch-gateway:true";async function g(r){const{data:n,ccipRequest:a}=r,{args:[o]}=k({abi:e.batchGatewayAbi,data:n}),t=[],s=[];return await Promise.all(o.map(async(c,i)=>{try{s[i]=c.urls.includes(b)?await g({data:c.data,ccipRequest:a}):await a(c),t[i]=!1}catch(f){t[i]=!0,s[i]=F(f)}})),L({abi:e.batchGatewayAbi,functionName:"query",result:[t,s]})}function F(r){return r.name==="HttpRequestError"&&r.status?y({abi:e.batchGatewayAbi,errorName:"HttpError",args:[r.status,r.shortMessage]}):y({abi:[e.solidityError],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}function O(r,n){if(!e.isAddress(r,{strict:!1}))throw new e.InvalidAddressError({address:r});if(!e.isAddress(n,{strict:!1}))throw new e.InvalidAddressError({address:n});return r.toLowerCase()===n.toLowerCase()}class P extends e.BaseError{constructor({callbackSelector:n,cause:a,data:o,extraData:t,sender:s,urls:c}){super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],a.metaMessages?.length?"":[],"Offchain Gateway Call:",c&&[" Gateway URL(s):",...c.map(i=>` ${e.getUrl(i)}`)],` Sender: ${s}`,` Data: ${o}`,` Callback selector: ${n}`,` Extra data: ${t}`].flat(),name:"OffchainLookupError"})}}class S extends e.BaseError{constructor({result:n,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e.getUrl(a)}`,`Response: ${e.stringify(n)}`],name:"OffchainLookupResponseMalformedError"})}}class x extends e.BaseError{constructor({sender:n,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${n}`],name:"OffchainLookupSenderMismatchError"})}}const M="0x556f1830",E={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function N(r,{blockNumber:n,blockTag:a,data:o,to:t}){const{args:s}=e.decodeErrorResult({data:o,abi:[E]}),[c,i,f,u,d]=s,{ccipRead:l}=r,w=l&&typeof l?.request=="function"?l.request:A;try{if(!O(t,c))throw new x({sender:c,to:t});const p=i.includes(b)?await g({data:f,ccipRequest:w}):await w({data:f,sender:c,urls:i}),{data:R}=await e.call(r,{blockNumber:n,blockTag:a,data:e.concat([u,e.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,d])]),to:t});return R}catch(p){throw new P({callbackSelector:u,cause:p,data:o,extraData:d,sender:c,urls:i})}}async function A({data:r,sender:n,urls:a}){let o=new Error("An unknown error occurred.");for(let t=0;t<a.length;t++){const s=a[t],c=s.includes("{data}")?"GET":"POST",i=c==="POST"?{data:r,sender:n}:void 0,f=c==="POST"?{"Content-Type":"application/json"}:{};try{const u=await fetch(s.replace("{sender}",n.toLowerCase()).replace("{data}",r),{body:JSON.stringify(i),headers:f,method:c});let d;if(u.headers.get("Content-Type")?.startsWith("application/json")?d=(await u.json()).data:d=await u.text(),!u.ok){o=new e.HttpRequestError({body:i,details:d?.error?e.stringify(d.error):u.statusText,headers:u.headers,status:u.status,url:s});continue}if(!e.isHex(d)){o=new S({result:d,url:s});continue}return d}catch(u){o=new e.HttpRequestError({body:i,details:u.message,url:s})}}throw o}exports.ccipRequest=A;exports.offchainLookup=N;exports.offchainLookupAbiItem=E;exports.offchainLookupSignature=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BfUc8rJl.cjs");function k(r){const{abi:n,data:a}=r,o=e.slice(a,0,4),t=n.find(s=>s.type==="function"&&o===e.toFunctionSelector(e.formatAbiItem(s)));if(!t)throw new e.AbiFunctionSignatureNotFoundError(o,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:t.name,args:"inputs"in t&&t.inputs&&t.inputs.length>0?e.decodeAbiParameters(t.inputs,e.slice(a,4)):void 0}}const h="/docs/contract/encodeErrorResult";function y(r){const{abi:n,errorName:a,args:o}=r;let t=n[0];if(a){const f=e.getAbiItem({abi:n,args:o,name:a});if(!f)throw new e.AbiErrorNotFoundError(a,{docsPath:h});t=f}if(t.type!=="error")throw new e.AbiErrorNotFoundError(void 0,{docsPath:h});const s=e.formatAbiItem(t),c=e.toFunctionSelector(s);let i="0x";if(o&&o.length>0){if(!t.inputs)throw new e.AbiErrorInputsNotFoundError(t.name,{docsPath:h});i=e.encodeAbiParameters(t.inputs,o)}return e.concatHex([c,i])}const m="/docs/contract/encodeFunctionResult";function L(r){const{abi:n,functionName:a,result:o}=r;let t=n[0];if(a){const c=e.getAbiItem({abi:n,name:a});if(!c)throw new e.AbiFunctionNotFoundError(a,{docsPath:m});t=c}if(t.type!=="function")throw new e.AbiFunctionNotFoundError(void 0,{docsPath:m});if(!t.outputs)throw new e.AbiFunctionOutputsNotFoundError(t.name,{docsPath:m});const s=(()=>{if(t.outputs.length===0)return[];if(t.outputs.length===1)return[o];if(Array.isArray(o))return o;throw new e.InvalidArrayError(o)})();return e.encodeAbiParameters(t.outputs,s)}const b="x-batch-gateway:true";async function g(r){const{data:n,ccipRequest:a}=r,{args:[o]}=k({abi:e.batchGatewayAbi,data:n}),t=[],s=[];return await Promise.all(o.map(async(c,i)=>{try{s[i]=c.urls.includes(b)?await g({data:c.data,ccipRequest:a}):await a(c),t[i]=!1}catch(f){t[i]=!0,s[i]=F(f)}})),L({abi:e.batchGatewayAbi,functionName:"query",result:[t,s]})}function F(r){return r.name==="HttpRequestError"&&r.status?y({abi:e.batchGatewayAbi,errorName:"HttpError",args:[r.status,r.shortMessage]}):y({abi:[e.solidityError],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}function O(r,n){if(!e.isAddress(r,{strict:!1}))throw new e.InvalidAddressError({address:r});if(!e.isAddress(n,{strict:!1}))throw new e.InvalidAddressError({address:n});return r.toLowerCase()===n.toLowerCase()}class P extends e.BaseError{constructor({callbackSelector:n,cause:a,data:o,extraData:t,sender:s,urls:c}){super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],a.metaMessages?.length?"":[],"Offchain Gateway Call:",c&&[" Gateway URL(s):",...c.map(i=>` ${e.getUrl(i)}`)],` Sender: ${s}`,` Data: ${o}`,` Callback selector: ${n}`,` Extra data: ${t}`].flat(),name:"OffchainLookupError"})}}class S extends e.BaseError{constructor({result:n,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e.getUrl(a)}`,`Response: ${e.stringify(n)}`],name:"OffchainLookupResponseMalformedError"})}}class x extends e.BaseError{constructor({sender:n,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${n}`],name:"OffchainLookupSenderMismatchError"})}}const M="0x556f1830",E={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function N(r,{blockNumber:n,blockTag:a,data:o,to:t}){const{args:s}=e.decodeErrorResult({data:o,abi:[E]}),[c,i,f,u,d]=s,{ccipRead:l}=r,w=l&&typeof l?.request=="function"?l.request:A;try{if(!O(t,c))throw new x({sender:c,to:t});const p=i.includes(b)?await g({data:f,ccipRequest:w}):await w({data:f,sender:c,urls:i}),{data:R}=await e.call(r,{blockNumber:n,blockTag:a,data:e.concat([u,e.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,d])]),to:t});return R}catch(p){throw new P({callbackSelector:u,cause:p,data:o,extraData:d,sender:c,urls:i})}}async function A({data:r,sender:n,urls:a}){let o=new Error("An unknown error occurred.");for(let t=0;t<a.length;t++){const s=a[t],c=s.includes("{data}")?"GET":"POST",i=c==="POST"?{data:r,sender:n}:void 0,f=c==="POST"?{"Content-Type":"application/json"}:{};try{const u=await fetch(s.replace("{sender}",n.toLowerCase()).replace("{data}",r),{body:JSON.stringify(i),headers:f,method:c});let d;if(u.headers.get("Content-Type")?.startsWith("application/json")?d=(await u.json()).data:d=await u.text(),!u.ok){o=new e.HttpRequestError({body:i,details:d?.error?e.stringify(d.error):u.statusText,headers:u.headers,status:u.status,url:s});continue}if(!e.isHex(d)){o=new S({result:d,url:s});continue}return d}catch(u){o=new e.HttpRequestError({body:i,details:u.message,url:s})}}throw o}exports.ccipRequest=A;exports.offchainLookup=N;exports.offchainLookupAbiItem=E;exports.offchainLookupSignature=M;
@@ -5,10 +5,12 @@ interface MulticoynButtonProps {
5
5
  currency?: string;
6
6
  items: PaymentItem[];
7
7
  settleInIDR?: boolean;
8
+ target?: `0x${string}`;
9
+ callData?: `0x${string}`;
8
10
  onPaymentComplete?: (result: PaymentResult) => void;
9
11
  onPaymentError?: (error: Error) => void;
10
12
  className?: string;
11
13
  children?: React.ReactNode;
12
14
  }
13
- export declare function MulticoynButton({ totalAmount, merchantAddress, currency, items, settleInIDR, onPaymentComplete, onPaymentError, className, children, }: MulticoynButtonProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function MulticoynButton({ totalAmount, merchantAddress, currency, items, settleInIDR, target, callData, onPaymentComplete, onPaymentError, className, children, }: MulticoynButtonProps): import("react/jsx-runtime").JSX.Element;
14
16
  export {};
@@ -21,6 +21,10 @@ export interface MulticoynButtonProps {
21
21
  currency?: string;
22
22
  items: PaymentItem[];
23
23
  tokens?: Token[];
24
+ merchantAddress: string;
25
+ settleInIDR?: boolean;
26
+ target?: `0x${string}`;
27
+ callData?: `0x${string}`;
24
28
  onPaymentComplete?: (result: PaymentResult) => void;
25
29
  onPaymentError?: (error: Error) => void;
26
30
  className?: string;
@@ -1,12 +1,12 @@
1
1
  export declare const CONTRACTS: {
2
- readonly PAYMENT_ROUTER: "0x7b3dfd5A3F3903237faC3D2de69d4c1915A09C9A";
3
- readonly TOKEN_REGISTRY: "0x8515a560284AedE5D78Ff5b73f2CeCa247DCAab7";
2
+ readonly PAYMENT_ROUTER: "0x73Dbc7447E3B097cFc8b08ee7896a9D27D67e2B4";
3
+ readonly TOKEN_REGISTRY: "0x1d2C6dfB2f127d6F3c14859c9E54cbc27bd7FcCE";
4
4
  };
5
5
  export declare const TOKENS: {
6
6
  readonly NATIVE: "0x0000000000000000000000000000000000000000";
7
- readonly USDC: "0x5DD8eEF51d251a53D6368CfD79a88F3BC186514B";
8
- readonly USDT: "0xc9013AD6e74A7dC418b2e601aaCD772044E59c22";
9
- readonly DAI: "0xF84851B3A4253b74813112A5488E38E724731E2a";
10
- readonly WBTC: "0x437f0b6328892ac36E01836aBc865d16c875D291";
11
- readonly IDRX: "0x5324Cd3e781cf85Cf63253138Ef6c6E84143de7B";
7
+ readonly USDC: "0x0Ff0aED4862e168086FD8BC38a4c27cE1830228b";
8
+ readonly USDT: "0xBc63b0cf19b757c2a6Ef646027f8CeA7Af2c3e7F";
9
+ readonly DAI: "0xd2aAa24D5C305B7968e955A89F0bf4E7776E7078";
10
+ readonly WBTC: "0x1BEC7ec7F995B9bcd93F411B2cE7d289C6b05f03";
11
+ readonly IDRX: "0x39B9205cDC53114c0B0F22F04C1215A13197b4d9";
12
12
  };
@@ -11,9 +11,11 @@ interface PaymentParams {
11
11
  tokens: Token[];
12
12
  totalAmountUSD: number;
13
13
  settleInIDR: boolean;
14
+ target?: `0x${string}`;
15
+ callData?: `0x${string}`;
14
16
  }
15
17
  export declare function usePaymentRouter(): {
16
- executePayment: ({ merchantAddress, tokens, totalAmountUSD, settleInIDR, }: PaymentParams) => Promise<`0x${string}`>;
18
+ executePayment: ({ merchantAddress, tokens, totalAmountUSD, settleInIDR, target, callData, }: PaymentParams) => Promise<`0x${string}`>;
17
19
  useTokenRegistry: () => import("wagmi").UseReadContractReturnType<({
18
20
  inputs: {
19
21
  internalType: string;