@unicitylabs/nostr-js-sdk 0.2.1 → 0.2.2
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 +14 -21
- package/dist/browser/index.js +3 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.min.js +1 -1
- package/dist/browser/index.min.js.map +1 -1
- package/dist/browser/index.umd.js +3 -2
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/browser/index.umd.min.js +1 -1
- package/dist/browser/index.umd.min.js.map +1 -1
- package/dist/cjs/client/NostrClient.js +3 -2
- package/dist/cjs/client/NostrClient.js.map +1 -1
- package/dist/esm/client/NostrClient.js +3 -2
- package/dist/esm/client/NostrClient.js.map +1 -1
- package/dist/types/client/NostrClient.d.ts +6 -1
- package/dist/types/client/NostrClient.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -177,31 +177,24 @@ client.unsubscribe(subId);
|
|
|
177
177
|
### Token Transfers
|
|
178
178
|
|
|
179
179
|
```typescript
|
|
180
|
-
import { TokenTransferProtocol } from '@unicitylabs/nostr-sdk';
|
|
180
|
+
import { NostrClient, TokenTransferProtocol } from '@unicitylabs/nostr-sdk';
|
|
181
181
|
|
|
182
|
-
//
|
|
183
|
-
const
|
|
184
|
-
keyManager,
|
|
185
|
-
recipientPubkey,
|
|
186
|
-
JSON.stringify({ tokenId: '...', amount: 100 }),
|
|
187
|
-
100n, // amount (optional metadata)
|
|
188
|
-
'UNIT' // symbol (optional metadata)
|
|
189
|
-
);
|
|
182
|
+
// Simple token transfer using NostrClient
|
|
183
|
+
const eventId = await client.sendTokenTransfer(recipientPubkey, tokenJson);
|
|
190
184
|
|
|
191
|
-
|
|
185
|
+
// Token transfer with metadata
|
|
186
|
+
const eventId = await client.sendTokenTransfer(recipientPubkey, tokenJson, {
|
|
187
|
+
amount: 100n,
|
|
188
|
+
symbol: 'UNIT'
|
|
189
|
+
});
|
|
192
190
|
|
|
193
|
-
//
|
|
191
|
+
// Token transfer in response to a payment request (with correlation)
|
|
194
192
|
const paymentRequestEventId = '...'; // Event ID of the original payment request
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
amount: 100n,
|
|
201
|
-
symbol: 'UNIT',
|
|
202
|
-
replyToEventId: paymentRequestEventId // Links transfer to the payment request
|
|
203
|
-
}
|
|
204
|
-
);
|
|
193
|
+
const eventId = await client.sendTokenTransfer(recipientPubkey, tokenJson, {
|
|
194
|
+
amount: 100n,
|
|
195
|
+
symbol: 'UNIT',
|
|
196
|
+
replyToEventId: paymentRequestEventId // Links transfer to the payment request
|
|
197
|
+
});
|
|
205
198
|
|
|
206
199
|
// Parse received token transfer
|
|
207
200
|
const tokenJson = await TokenTransferProtocol.parseTokenTransfer(event, keyManager);
|
package/dist/browser/index.js
CHANGED
|
@@ -6354,11 +6354,12 @@ class NostrClient {
|
|
|
6354
6354
|
* Send a token transfer (encrypted).
|
|
6355
6355
|
* @param recipientPubkeyHex Recipient's public key (hex)
|
|
6356
6356
|
* @param tokenJson Token JSON string
|
|
6357
|
+
* @param options Optional parameters (amount, symbol, replyToEventId)
|
|
6357
6358
|
* @returns Promise that resolves with the event ID
|
|
6358
6359
|
*/
|
|
6359
|
-
async sendTokenTransfer(recipientPubkeyHex, tokenJson) {
|
|
6360
|
+
async sendTokenTransfer(recipientPubkeyHex, tokenJson, options) {
|
|
6360
6361
|
const TokenTransferProtocol$1 = await Promise.resolve().then(function () { return TokenTransferProtocol; });
|
|
6361
|
-
const event = await TokenTransferProtocol$1.createTokenTransferEvent(this.keyManager, recipientPubkeyHex, tokenJson);
|
|
6362
|
+
const event = await TokenTransferProtocol$1.createTokenTransferEvent(this.keyManager, recipientPubkeyHex, tokenJson, options);
|
|
6362
6363
|
return this.publishEvent(event);
|
|
6363
6364
|
}
|
|
6364
6365
|
/**
|