@oneswap/dapp-sdk 0.1.0 → 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/README.md +4 -2
- package/example/server.mjs +3 -1
- package/package.json +1 -1
- package/server.d.ts +2 -2
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ Connect a OneSwap Wallet to your website, check holder eligibility with user con
|
|
|
5
5
|
## Install and register your site
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install @oneswap/dapp-sdk@0.
|
|
8
|
+
npm install @oneswap/dapp-sdk@0.2.0
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Start on DevNet. Open **My launches → dApps** with the token's creator wallet, choose the token, register its official HTTPS website and callback, verify the domain, and create a server key. Save the app ID and secret in your backend’s secret store. Configure holder requirements and experiences in the same tab.
|
|
11
|
+
Start on DevNet. Open **My launches → dApps** with the token's creator wallet, choose the token, register its official HTTPS website and callback, verify the domain, and create a server key. Save the app ID and secret in your backend’s secret store. Configure holder requirements and experiences in the same tab. [DevNet dashboard](https://devnet.oneswap.cc/launchpad/launches?tab=dapps) · [Creator integration guide](https://docs.oneswap.cc/guides/creator-dapp-sdk)
|
|
12
12
|
|
|
13
13
|
Choose the network explicitly on the server and in browser calls. Use each network’s own registration, callback, credentials and order records.
|
|
14
14
|
|
|
@@ -107,6 +107,8 @@ const receipt = await sdk.rewards.receipt(session.accessToken, batch.id);
|
|
|
107
107
|
|
|
108
108
|
The creator reviews the exact recipients, amounts and fee, approves the batch and funds it from their own wallet. A recipient may need to accept the transfer. Show delivery only when the member’s receipt reports `delivered`. A proposed or funded batch can still be pending.
|
|
109
109
|
|
|
110
|
+
In **My launches → dApps → Reward batches**, the creator can dismiss an unapproved draft. This frees a draft slot and closes the batch. A retry with the same event ID and awards returns the original dismissed batch. Handle `dismissed` as a terminal outcome with no payout.
|
|
111
|
+
|
|
110
112
|
## Run the included example
|
|
111
113
|
|
|
112
114
|
The membership-site example requires **Node.js 22.13+** for `node:sqlite`. Install the package in your project and configure `DAPP_NETWORK=devnet`, `DAPP_ID`, `DAPP_SECRET` and `EXAMPLE_ORIGIN` in your server environment. Use your exact registered HTTPS origin, with its callback at `/callback`. Set `RULE_ID` for holder access and `EXPERIENCE_ID` for checkout.
|
package/example/server.mjs
CHANGED
|
@@ -379,7 +379,9 @@ createServer(async (req, res) => {
|
|
|
379
379
|
if (rewardBatch) {
|
|
380
380
|
try {
|
|
381
381
|
const r = await sdk.rewards.receipt(session.access, rewardBatch);
|
|
382
|
-
body += '<h2>Your reward</h2><p>
|
|
382
|
+
body += '<h2>Your reward</h2><p>' + (r.status === 'dismissed'
|
|
383
|
+
? 'The creator dismissed this reward proposal before funding.'
|
|
384
|
+
: 'Receipt status: ' + escape(r.status) + '.') + '</p>';
|
|
383
385
|
} catch (e) {
|
|
384
386
|
if (e.status !== 404) throw e;
|
|
385
387
|
}
|
package/package.json
CHANGED
package/server.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export type ExpectedPayment = Pick<Payment, 'id'|'orderId'|'subject'|'experience
|
|
|
15
15
|
export function isPaidReceiptFor(receipt:unknown,order:ExpectedPayment):boolean;
|
|
16
16
|
export interface Award {recipientId:string;amount:string}
|
|
17
17
|
export type RewardAsset={instrumentAdmin:string;tokenId:string};
|
|
18
|
-
export type RewardBatch={id:string;eventId:string;status:'draft'|'approved';planHash:string;totalAmount:string;recipientCount:number;asset:RewardAsset;campaignId:string|null;networkFeeCc:string|null;createdAt:string};
|
|
19
|
-
export type RewardReceipt={batchId:string;eventId:string;status:'pending_approval'}|{
|
|
18
|
+
export type RewardBatch={id:string;eventId:string;status:'draft'|'approved'|'dismissed';planHash:string;totalAmount:string;recipientCount:number;asset:RewardAsset;campaignId:string|null;networkFeeCc:string|null;createdAt:string};
|
|
19
|
+
export type RewardReceipt={batchId:string;eventId:string;status:'pending_approval'}|{batchId:string;eventId:string;status:'dismissed'}|{
|
|
20
20
|
batchId:string;eventId:string;campaignId:string;amount:string;asset:RewardAsset;
|
|
21
21
|
status:'pending'|'awaiting_acceptance'|'delivered'|'returned'|'unknown';expiresAt?:string;
|
|
22
22
|
receipt?:{recordedAt:string;updateId:string}
|