warp-contracts / warp

An implementation of the Arweave SmartWeave smart contracts protocol.
MIT License
159 stars 44 forks source link

fix: EvmSignature bundling problem #285

Closed koonopek closed 2 years ago

koonopek commented 2 years ago

I'm using next.js for bundling:

    "node": "16.5.0"
  },
  "dependencies": {
    "@apollo/client": "^3.7.1",
    "ethers": "^5.7.2",
    "graphql": "^16.6.0",
    "next": "13.0.5",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "warp-contracts": "^1.2.30",
    "warp-signature": "^1.0.5"
  }

Error when running: next dev

  }`),Rs(xs,"_30seconds",30*1e3);var Xa=class{constructor(e){this.delegate=e}logger=Ae.INST.create("CacheableInteractionsLoader");interactionsCache=new Map;async load(e,t,n,i){if(this.logger.debug("Loading interactions for",{contractTxId:e,fromSortKey:t,toSortKey:n}),this.interactionsCache.has(e)){let o=this.interactionsCache.get(e);if(o?.length){let s=o[o.length-1].sortKey;if(s.localeCompare(n)<0){let f=await this.delegate.load(e,s,n,i),h=o.concat(f);return this.interactionsCache.set(e,h),h}}return o}else{let o=await 
...
...
SourceType,_r as TagsParser,so as WARP_GW_URL,Ts as Warp,Du as WarpBuilder,F6 as WarpFactory,Lu as WarpGatewayContractDefinitionLoader,uu as WarpGatewayInteractionsLoader,gu as WasmHandlerApi,As as WasmSrc,G2 as arrayToHex,tC as asc,rC as ascS,cw as bufToBn,a6 as bundledTxsFilter,Dd as canBeCached,r6 as createDummyTx,gp as createInteractionTx,ka as deepCopy,tf as defaultCacheOptions,Ep as defaultWarpGwOptions,nC as desc,iC as descS,ao as emptyTransfer,qd as genesisSortKey,Kr as indent,La as isBrowser,uw as isomorphicRandomUUID,A6 as knownWarpPlugins,sB as lastPossibleKey,Hu as lvlToOrder,ZI as mapReplacer,eC as mapReviver,hx as normalizeContractSource,$c as sleep,IA as sortingFirst,V2 as sortingLast,Hc as stripTrailingSlash,fw as timeout};

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1088:15)
    at Module._compile (node:internal/modules/cjs/loader:1123:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/michalkonopka/code/github.com/lens-app/node_modules/warp-signature/build/web/evm/evmSignature.js:11:15)
    at Module._compile (node:internal/modules/cjs/loader:1159:14) {
  page: '/'
}

Problem doesn't occur in version: warp-signature@1.0.4

koonopek commented 2 years ago

Workaround for next.js: const { evmSignature, EvmSignatureVerificationWebPlugin } = await import('warp-signature');

solution in doc: https://nextjs.org/docs/advanced-features/dynamic-import#with-external-libraries thread: https://github.com/vercel/next.js/issues/31518#issuecomment-991943823 drawback: we have to use async import