diff --git a/demo/draft/alice/list.ts b/demo/draft/alice/list.ts index 9c48c7fd..59077082 100644 --- a/demo/draft/alice/list.ts +++ b/demo/draft/alice/list.ts @@ -8,14 +8,6 @@ import { signer } from './config.js' console.log(signer.pubkey) -const session = new DraftSession(signer, { - socket_config : { verbose : true, debug : true }, - store_config : { verbose : true, debug : false }, - verbose : true -}) - -const drafts = await session.list('wss://relay.damus.io') +const drafts = await DraftSession.list('wss://relay.damus.io', signer, { verbose : true }) console.dir(drafts, { depth : null }) - -session.delete(drafts[0].store_id) diff --git a/package.json b/package.json index fc680de2..3b40a7bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@scrow/core", - "version": "0.7.21", + "version": "0.7.22", "description": "Core library for BitEscrow API.", "author": "Christopher Scott", "license": "MIT", @@ -122,7 +122,7 @@ "@cmdcode/buff": "2.2.5", "@cmdcode/crypto-tools": "2.7.6", "@cmdcode/musig2": "2.4.3", - "@cmdcode/nostr-sdk": "^0.0.3", + "@cmdcode/nostr-sdk": "^0.0.4", "@cmdcode/signer": "1.4.2", "@scrow/tapscript": "2.2.2", "zod": "^3.22.4" diff --git a/rollup.config.ts b/rollup.config.ts index 66a651c7..c0b79b71 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -39,10 +39,13 @@ export default { format: 'iife', name: 'escrow_core', plugins: [terser()], - sourcemap: true + sourcemap: true, + globals : { + 'ws' : 'WebSocket' + } } ], - external : ['websocket'], + external : ['ws'], plugins: [ typescript(), nodeResolve(), commonjs() ], strictDeprecations: true, treeshake diff --git a/src/client/class/draft.ts b/src/client/class/draft.ts index b6dc2a10..3bbd6644 100644 --- a/src/client/class/draft.ts +++ b/src/client/class/draft.ts @@ -3,10 +3,12 @@ import { EventEmitter } from './emitter.js' import { EscrowSigner } from './signer.js' import { EscrowContract } from './contract.js' import { EscrowClient } from './client.js' +import { DraftItem } from '../types.js' import { EventMessage, - NostrRoom + NostrRoom, + SocketConfig } from '@cmdcode/nostr-sdk' import { @@ -76,6 +78,14 @@ export class DraftSession extends EventEmitter <{ 'published' : string }> { + static async list ( + address : string, + signer : EscrowSigner, + options ?: Partial + ) : Promise { + return NostrRoom.list(address, signer._signer, undefined, options) + } + readonly _opt : SessionConfig readonly _signer : EscrowSigner readonly _room : NostrRoom diff --git a/src/client/types.ts b/src/client/types.ts index 32886272..c7bdb1b4 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -29,9 +29,9 @@ export interface FetchConfig { export interface DraftItem { pubkey : string, - id : string, secret : string, store_id : string, + topic_id : string, updated_at : number } diff --git a/yarn.lock b/yarn.lock index 38e91128..5fedbdf5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -37,10 +37,10 @@ "@cmdcode/buff" "^2.2.5" "@cmdcode/crypto-tools" "^2.7.6" -"@cmdcode/nostr-sdk@^0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@cmdcode/nostr-sdk/-/nostr-sdk-0.0.3.tgz#0681c0afb6eb634aa63ff89481c87997afb939c1" - integrity sha512-qTMz2x+OXcHrD/hXmRVc3G4OKiMpwf1/7CqzRk4tqh8xxe3ei0kMt7xlyaiOENEe34pNY6p1FoldoKz7m43fNA== +"@cmdcode/nostr-sdk@^0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@cmdcode/nostr-sdk/-/nostr-sdk-0.0.4.tgz#6c50456444a8ec7fc9a65333849c77bee1b3a07a" + integrity sha512-mG9FK1X0pupdgUJywH/gETvWbALuylcE7DKaqH6Mt76dBDletgKik84Vn6DVHMH1dX4UZMeID/PWSU6E1BCi/w== dependencies: "@cmdcode/buff" "2.2.5" "@cmdcode/crypto-tools" "2.7.6"