droplinked-web3-ui 0.0.9 → 0.0.11

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/index.js CHANGED
@@ -14276,11 +14276,14 @@ async function updateUris(n, t, c) {
14276
14276
  })).json()).data;
14277
14277
  }
14278
14278
  async function updateHash(n, t, c, ie) {
14279
- return (await (await ie.put(`web3/${n}/transactions/${t}/hash`, {
14280
- json: {
14281
- transactionHash: c
14279
+ return (await (await ie.put(
14280
+ `web3/${n}/transactions/${t}/hash`,
14281
+ {
14282
+ json: {
14283
+ transactionHash: c
14284
+ }
14282
14285
  }
14283
- })).json()).data;
14286
+ )).json()).data;
14284
14287
  }
14285
14288
  async function getProductDataForRecord(n, t) {
14286
14289
  if (!n)
@@ -14308,7 +14311,10 @@ async function getAddress(n, t, c) {
14308
14311
  const se = t === Network.TESTNET ? "apiv3dev" : "apiv3", ae = ie(n), ue = ie(Network[t]), de = `https://${se}.droplinked.com/storage/${ae}${ue}ContractAddress${c}`;
14309
14312
  return (await await ky.get(de).json()).value;
14310
14313
  } catch (se) {
14311
- throw console.error(`Failed to fetch ${c.toLowerCase()} address:`, se), new Error(`Unable to get ${c.toLowerCase()} address`);
14314
+ throw console.error(
14315
+ `Failed to fetch ${c.toLowerCase()} address:`,
14316
+ se
14317
+ ), new Error(`Unable to get ${c.toLowerCase()} address`);
14312
14318
  }
14313
14319
  }
14314
14320
  async function getDeployerAddress(n, t) {
@@ -14328,7 +14334,9 @@ async function startPayment(n, t, c, ie, se) {
14328
14334
  })).json()).data.id;
14329
14335
  }
14330
14336
  async function getCartData(n, t, c, ie) {
14331
- const se = await (await ie.get(`web3/payment/distribution/${n}/${t}/${c}`)).json();
14337
+ const se = await (await ie.get(
14338
+ `web3/payment/distribution/${n}/${t}/${c}`
14339
+ )).json();
14332
14340
  return {
14333
14341
  paymentData: se.data,
14334
14342
  orderID: se.orderID
@@ -14336,12 +14344,21 @@ async function getCartData(n, t, c, ie) {
14336
14344
  }
14337
14345
  async function getPurchaseSignature(n, t, c) {
14338
14346
  const ie = await (await c.get(`nfts/by-order?orderId=${n}&skuId=${t}`)).json();
14339
- return {
14347
+ return console.log("Purchase signature response:", ie), {
14340
14348
  signature: ie.purchaseSignature,
14341
14349
  shopContractAddress: ie.shopContractAddress,
14342
- networkName: ie.networkName
14350
+ networkName: ie.networkName,
14351
+ nftId: ie._id
14343
14352
  };
14344
14353
  }
14354
+ async function sendClaim(n, t, c) {
14355
+ return await (await c.post("nfts/transfer", {
14356
+ json: {
14357
+ transactionId: t,
14358
+ nftId: n
14359
+ }
14360
+ })).json();
14361
+ }
14345
14362
  async function getShopByteCode() {
14346
14363
  try {
14347
14364
  return String((await await ky.get("https://apiv3dev.droplinked.com/storage/shopByteCodeType0").json()).value);
@@ -17572,7 +17589,11 @@ const DROPLINKED_MANAGER = "0x2F86E1B1A69D259b9609b40E3cbEBEa29946f979";
17572
17589
  async function doClaimNFT(n, t, c) {
17573
17590
  const { modalInterface: ie } = c, se = t.provider.getSigner();
17574
17591
  ie.changeStep("Claiming NFTs");
17575
- const ae = new Contract(c.shopContractAddress, shopABI, se);
17592
+ const ae = new Contract(
17593
+ c.shopContractAddress,
17594
+ shopABI,
17595
+ se
17596
+ );
17576
17597
  try {
17577
17598
  console.log(DROPLINKED_MANAGER, n.signature.signature, {
17578
17599
  cart: n.signature.purchaseData.map((be) => ({
@@ -17588,10 +17609,14 @@ async function doClaimNFT(n, t, c) {
17588
17609
  nullifier: BigNumber.from(be.nullifier)
17589
17610
  }));
17590
17611
  ie.changeStep("Sending Transaction");
17591
- const de = await ae.claimPurchase(DROPLINKED_MANAGER, n.signature.signature, {
17592
- cart: ue,
17593
- shop: c.shopContractAddress
17594
- });
17612
+ const de = await ae.claimPurchase(
17613
+ DROPLINKED_MANAGER,
17614
+ n.signature.signature,
17615
+ {
17616
+ cart: ue,
17617
+ shop: c.shopContractAddress
17618
+ }
17619
+ );
17595
17620
  return ie.changeStep("Waiting for confirmation"), await de.wait(), ie.changeStep("NFT Claimed!"), {
17596
17621
  transactionHash: de.hash
17597
17622
  };
@@ -17620,12 +17645,13 @@ async function claimNFT({
17620
17645
  skuId: se,
17621
17646
  network: ae
17622
17647
  }) {
17623
- const ue = new Web3Provider(n, "any"), { shopContractAddress: de, signature: be, networkName: me } = await getPurchaseSignature(
17624
- ie,
17625
- se,
17626
- t
17648
+ const ue = new Web3Provider(n, "any"), { shopContractAddress: de, signature: be, networkName: me, nftId: we } = await getPurchaseSignature(ie, se, t);
17649
+ await ensureWalletOnChainFromConfig(
17650
+ ue,
17651
+ getChainByName(me),
17652
+ ae
17627
17653
  );
17628
- return await ensureWalletOnChainFromConfig(ue, getChainByName(me), ae), await doClaimNFT(
17654
+ const Te = await doClaimNFT(
17629
17655
  {
17630
17656
  signature: be
17631
17657
  },
@@ -17639,6 +17665,7 @@ async function claimNFT({
17639
17665
  shopContractAddress: de
17640
17666
  }
17641
17667
  );
17668
+ return await sendClaim(we, Te.transactionHash, t), Te;
17642
17669
  }
17643
17670
  class EVMBaseWallet extends Web3Wallet {
17644
17671
  constructor(t, c) {
@@ -75398,45 +75425,72 @@ appDevelopment && usePaymentUiStore.subscribe((n, t) => {
75398
75425
  nextState: n
75399
75426
  });
75400
75427
  });
75401
- const DropWeb3Context = createContext$2(null);
75428
+ const DropWeb3Context = createContext$2(null), useClaimNftStore = create((n) => ({
75429
+ orderId: "",
75430
+ skuId: "",
75431
+ onError: () => {
75432
+ },
75433
+ onMainProcessSuccess: () => {
75434
+ },
75435
+ buttonText: "Claim NFT",
75436
+ isButtonDisabled: !1,
75437
+ currentDescription: "",
75438
+ currentError: "",
75439
+ currentErrorDescription: "",
75440
+ setClaimNftData: (t) => n((c) => ({
75441
+ ...c,
75442
+ ...t
75443
+ }))
75444
+ }));
75402
75445
  function DropWeb3Provider(n) {
75403
- const t = compilerRuntimeExports.c(11), {
75446
+ const t = compilerRuntimeExports.c(14), {
75404
75447
  children: c
75405
75448
  } = n, {
75406
75449
  setPaymentUiData: ie,
75407
75450
  onError: se
75408
- } = usePaymentUiStore();
75409
- let ae;
75410
- t[0] !== se || t[1] !== ie ? (ae = new DropWeb3(appDevelopment ? Network.TESTNET : Network.MAINNET, {
75411
- async changeStep(Te) {
75451
+ } = usePaymentUiStore(), {
75452
+ setClaimNftData: ae,
75453
+ onError: ue,
75454
+ skuId: de
75455
+ } = useClaimNftStore();
75456
+ let be;
75457
+ t[0] !== ue || t[1] !== se || t[2] !== ae || t[3] !== ie || t[4] !== de ? (be = new DropWeb3(appDevelopment ? Network.TESTNET : Network.MAINNET, {
75458
+ async changeStep(ze) {
75412
75459
  ie({
75413
- currentDescription: Te
75460
+ currentDescription: ze
75461
+ }), de && ae({
75462
+ currentDescription: ze
75414
75463
  });
75415
75464
  },
75416
- async error(Te, Ne) {
75465
+ async error(ze, He) {
75417
75466
  ie({
75418
- currentError: Te,
75419
- currentErrorDescription: Ne
75420
- }), se(Te);
75421
- },
75422
- async success(Te) {
75467
+ currentError: ze,
75468
+ currentErrorDescription: He
75469
+ }), de && (ae({
75470
+ currentError: ze,
75471
+ currentErrorDescription: He
75472
+ }), ue(ze)), se(ze);
75473
+ },
75474
+ async success(ze) {
75423
75475
  ie({
75424
- currentDescription: Te
75476
+ currentDescription: ze
75477
+ }), de && ae({
75478
+ currentDescription: ze
75425
75479
  });
75426
75480
  },
75427
75481
  name: "custom-stepizer"
75428
- }), t[0] = se, t[1] = ie, t[2] = ae) : ae = t[2];
75429
- const ue = ae;
75430
- let de;
75431
- t[3] !== ue ? (de = ue.getProvider(), t[3] = ue, t[4] = de) : de = t[4];
75432
- const be = de;
75433
- let me;
75434
- t[5] !== be || t[6] !== ue ? (me = {
75435
- web3: ue,
75436
- provider: be
75437
- }, t[5] = be, t[6] = ue, t[7] = me) : me = t[7];
75482
+ }), t[0] = ue, t[1] = se, t[2] = ae, t[3] = ie, t[4] = de, t[5] = be) : be = t[5];
75483
+ const me = be;
75438
75484
  let we;
75439
- return t[8] !== c || t[9] !== me ? (we = /* @__PURE__ */ jsxRuntimeExports.jsx(DropWeb3Context.Provider, { value: me, children: c }), t[8] = c, t[9] = me, t[10] = we) : we = t[10], we;
75485
+ t[6] !== me ? (we = me.getProvider(), t[6] = me, t[7] = we) : we = t[7];
75486
+ const Te = we;
75487
+ let Ne;
75488
+ t[8] !== Te || t[9] !== me ? (Ne = {
75489
+ web3: me,
75490
+ provider: Te
75491
+ }, t[8] = Te, t[9] = me, t[10] = Ne) : Ne = t[10];
75492
+ let qe;
75493
+ return t[11] !== c || t[12] !== Ne ? (qe = /* @__PURE__ */ jsxRuntimeExports.jsx(DropWeb3Context.Provider, { value: Ne, children: c }), t[11] = c, t[12] = Ne, t[13] = qe) : qe = t[13], qe;
75440
75494
  }
75441
75495
  const IconCoins = (n) => {
75442
75496
  const t = compilerRuntimeExports.c(3);
@@ -106911,23 +106965,7 @@ function DroplinkedWeb3Ui(n) {
106911
106965
  let ie;
106912
106966
  return t[2] !== c ? (ie = /* @__PURE__ */ jsxRuntimeExports.jsx(Dn, { system: an, children: /* @__PURE__ */ jsxRuntimeExports.jsx(QueryClientProvider, { client: queryClient$1, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PaymentUi, { ...c }) }) }), t[2] = c, t[3] = ie) : ie = t[3], ie;
106913
106967
  }
106914
- const useClaimNftStore = create((n) => ({
106915
- orderId: "",
106916
- skuId: "",
106917
- onError: () => {
106918
- },
106919
- onMainProcessSuccess: () => {
106920
- },
106921
- buttonText: "Claim NFT",
106922
- isButtonDisabled: !1,
106923
- currentDescription: "",
106924
- currentError: "",
106925
- currentErrorDescription: "",
106926
- setClaimNftData: (t) => n((c) => ({
106927
- ...c,
106928
- ...t
106929
- }))
106930
- })), getStatusTitle = (n, t) => {
106968
+ const getStatusTitle = (n, t) => {
106931
106969
  switch (t) {
106932
106970
  case "loading":
106933
106971
  return "Opening Wallet and Claiming NFT...";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "droplinked-web3-ui",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "@emotion/react": "^11.14.0",
28
28
  "axios": "^1.13.5",
29
29
  "droplinked-ui-kit": "^0.0.38",
30
- "droplinked-web3-kit": "^1.0.6",
30
+ "droplinked-web3-kit": "^1.0.7",
31
31
  "react": "^19.2.0",
32
32
  "react-dom": "^19.2.0",
33
33
  "react-query": "^3.39.3",