@realmint/sdk 0.2.3 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # @realmint/sdk
2
2
 
3
- TypeScript SDK for the [Realmint](https://realmint.io) API — **list, buy, and
4
- sell** tokenized real-world assets. Non-custodial: you inject the signer, the
3
+ TypeScript SDK for the [Realmint](https://realmint.io) API — **list, buy, sell,
4
+ and withdraw** tokenized real-world assets. Non-custodial: you inject the signer, the
5
5
  SDK never holds keys. Gas is sponsored in USDC (no native gas needed), and
6
6
  funding is over [x402](https://x402.org).
7
7
 
@@ -82,6 +82,26 @@ const sold = await client.sellSolana(
82
82
  );
83
83
  ```
84
84
 
85
+ ## Withdraw / send
86
+
87
+ Move funds out of your smart account to any address — gasless (paymaster-sponsored),
88
+ one UserOp signature (same signer as `buy`). Works for both the keyless agent
89
+ identity and Privy human identity.
90
+
91
+ ```ts
92
+ const res = await client.withdraw(
93
+ {
94
+ chain_id: 1776, // Injective
95
+ owner_eoa: account.address,
96
+ token_address: "0xa00C59fF5a080D2b954d0c75e46E22a0c371235a", // native USDC
97
+ recipient: "0x…",
98
+ amount_raw: "4800000", // 4.8 USDC (6 decimals)
99
+ },
100
+ signUserOpHash,
101
+ );
102
+ // res.mode === "bundler", res.user_op_hash set
103
+ ```
104
+
85
105
  ## Fund with x402
86
106
 
87
107
  ```ts
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AccountStatus, CreateIntentParams, CreateIntentResponse, ExecuteResponse, GetIntentResponse, Hex, PrepareResponse, PrepareSolanaSellResponse, RealmintClientOptions, RouteIntent, SignSolanaWire, SignUserOpHash } from "./types.js";
1
+ import type { AccountStatus, CreateIntentParams, CreateIntentResponse, ExecuteResponse, GetIntentResponse, Hex, PrepareResponse, PrepareSolanaSellResponse, RealmintClientOptions, RouteIntent, SignSolanaWire, SignUserOpHash, SubmitTransferResponse, WithdrawParams } from "./types.js";
2
2
  export declare class RealmintError extends Error {
3
3
  readonly status: number;
4
4
  readonly body: unknown;
@@ -81,4 +81,12 @@ export declare class RealmintClient {
81
81
  * → poll. One Solana signature; gas is relayer-sponsored.
82
82
  */
83
83
  sellSolana(params: Omit<CreateIntentParams, "action">, signWire: SignSolanaWire, opts?: WaitOptions): Promise<RouteIntent>;
84
+ /**
85
+ * Withdraw / send an ERC-20 from the caller's smart account to any address:
86
+ * prepare → sign the UserOp hash → submit. Gasless (paymaster-sponsored).
87
+ * Works for both Privy human and keyless-agent identities (the latter requires
88
+ * the server's `REALMINT_AGENT_WITHDRAW_ENABLED` flag). `sign` is the same
89
+ * UserOp-hash signer used by `buy`.
90
+ */
91
+ withdraw(params: WithdrawParams, sign: SignUserOpHash): Promise<SubmitTransferResponse>;
84
92
  }
package/dist/client.js CHANGED
@@ -239,6 +239,22 @@ export class RealmintClient {
239
239
  await this.submitSolanaSell(created.intent_id, signed);
240
240
  return this.waitForSettlement(created.intent_id, opts);
241
241
  }
242
+ /**
243
+ * Withdraw / send an ERC-20 from the caller's smart account to any address:
244
+ * prepare → sign the UserOp hash → submit. Gasless (paymaster-sponsored).
245
+ * Works for both Privy human and keyless-agent identities (the latter requires
246
+ * the server's `REALMINT_AGENT_WITHDRAW_ENABLED` flag). `sign` is the same
247
+ * UserOp-hash signer used by `buy`.
248
+ */
249
+ async withdraw(params, sign) {
250
+ const prep = await this.request("POST", "/v1/wallet/prepare-transfer", params);
251
+ const signature = await sign(prep.user_op_hash);
252
+ const signedUserOp = { ...prep.user_op, signature };
253
+ return this.request("POST", "/v1/wallet/submit-transfer", {
254
+ ...params,
255
+ user_op: signedUserOp,
256
+ });
257
+ }
242
258
  }
243
259
  function safeJson(text) {
244
260
  try {
package/dist/types.d.ts CHANGED
@@ -102,6 +102,30 @@ export interface PrepareSolanaSellResponse {
102
102
  /** The Solana pubkey expected to co-sign (the seller's Realmint Wallet). */
103
103
  signer: string;
104
104
  }
105
+ /** Move an ERC-20 out of the caller's smart account (withdraw / send). */
106
+ export interface WithdrawParams {
107
+ chain_id: number;
108
+ /** EOA that owns the smart account (must be the caller's identity). */
109
+ owner_eoa: string;
110
+ token_address: string;
111
+ recipient: string;
112
+ /** Raw on-chain unit amount (decimal string, e.g. "4800000" for 4.8 USDC). */
113
+ amount_raw: string;
114
+ }
115
+ export interface PrepareTransferResponse {
116
+ user_op: UnsignedUserOp;
117
+ /** EIP-191 personal_sign digest — same shape as a buy's source_user_op_hash. */
118
+ user_op_hash: Hex;
119
+ entrypoint_address: string;
120
+ smart_account_address: string;
121
+ chain_id: number;
122
+ }
123
+ export interface SubmitTransferResponse {
124
+ /** "bundler" (source chain) or "direct" (destination chains). */
125
+ mode: string;
126
+ user_op_hash: string;
127
+ tx_hash: string | null;
128
+ }
105
129
  /** Terminal-ish states the SDK's waiters stop on. */
106
130
  export declare const TERMINAL_STATES: readonly ["completed", "terminal_failed", "expired", "cancelled"];
107
131
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realmint/sdk",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "TypeScript SDK for the Realmint API — list, buy, and sell tokenized RWAs (non-custodial; the partner's signer signs).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,10 +15,6 @@
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
- "scripts": {
19
- "build": "tsc -p tsconfig.json",
20
- "typecheck": "tsc -p tsconfig.json --noEmit"
21
- },
22
18
  "keywords": [
23
19
  "realmint",
24
20
  "rwa",
@@ -31,5 +27,9 @@
31
27
  },
32
28
  "devDependencies": {
33
29
  "typescript": "^5.4.0"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.json",
33
+ "typecheck": "tsc -p tsconfig.json --noEmit"
34
34
  }
35
- }
35
+ }