@fivenorth/loop-sdk 0.9.0 → 0.10.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.
Files changed (3) hide show
  1. package/README.md +7 -7
  2. package/dist/index.js +80 -36
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -142,6 +142,7 @@ try {
142
142
  const result = await provider.submitTransaction(damlCommand, {
143
143
  // Optional: show a custom message in the wallet prompt
144
144
  message: 'Transfer 10 CC to RetailStore',
145
+ estimateTraffic: true, // optional: return estimated traffic in submission response
145
146
  });
146
147
  console.log('Transaction successful:', result);
147
148
  } catch (error) {
@@ -186,19 +187,19 @@ try {
186
187
  ```javascript
187
188
  await loop.wallet.transfer(
188
189
  'receiver::fingerprint',
189
- '5', // amount (string or number)
190
+ '5',
190
191
  {
191
- // Optional overrides. Defaults to Amulet/DSO if omitted.
192
- instrument_admin: 'issuer::fingerprint', // optional
193
- instrument_id: 'Amulet', // optional
192
+ instrument_admin: 'issuer::fingerprint', // optional: DSO (default)
193
+ instrument_id: 'Amulet', // optional: Amulet (default)
194
194
  },
195
195
  {
196
- // Optional: show a custom message in the wallet prompt
197
- message: 'Send 5 CC to Alice',
196
+ message: 'Send 5 CC to Alice', // optional: show a custom message in the wallet prompt
197
+ memo: 'optional memo for the transfer', // optional: stored as transfer metadata
198
198
  executionMode: 'wait', // optional: 'async' (default) or 'wait'
199
199
  requestedAt: new Date().toISOString(), // optional
200
200
  executeBefore: new Date(Date.now() + 24*60*60*1000).toISOString(), // optional
201
201
  requestTimeout: 5 * 60 * 1000, // optional (ms), defaults to 5 minutes
202
+ estimateTraffic: true, // optional: return estimated traffic in submission response
202
203
  },
203
204
  );
204
205
  ```
@@ -206,7 +207,6 @@ await loop.wallet.transfer(
206
207
  Notes:
207
208
  - You must have spendable holdings for the specified instrument (admin + id). If left blank, the SDK defaults to the native token.
208
209
  - The helper handles fetching holdings, building the transfer factory payload, and submitting via Wallet Connect.
209
- - Requests time out after 5 minutes by default; override with `requestTimeout` in milliseconds.
210
210
 
211
211
  Common instrument overrides (pass into the `instrument` argument above):
212
212
 
package/dist/index.js CHANGED
@@ -2204,6 +2204,9 @@ class Connection {
2204
2204
  if (params.execute_before) {
2205
2205
  payload.execute_before = params.execute_before;
2206
2206
  }
2207
+ if (params.memo) {
2208
+ payload.memo = params.memo;
2209
+ }
2207
2210
  const response = await fetch(`${this.apiUrl}/api/v1/.connect/pair/transfer`, {
2208
2211
  method: "POST",
2209
2212
  headers: {
@@ -2396,14 +2399,16 @@ class Provider {
2396
2399
  return this.connection.getActiveContracts(this.auth_token, params);
2397
2400
  }
2398
2401
  async submitTransaction(payload, options) {
2399
- return this.sendRequest("run_transaction" /* RUN_TRANSACTION */, payload, options);
2402
+ const requestPayload = options?.estimateTraffic ? { ...payload, estimate_traffic: true } : payload;
2403
+ return this.sendRequest("run_transaction" /* RUN_TRANSACTION */, requestPayload, options);
2400
2404
  }
2401
2405
  async submitAndWaitForTransaction(payload, options) {
2402
- return this.sendRequest("run_transaction" /* RUN_TRANSACTION */, { ...payload, execution_mode: "wait" }, options);
2406
+ const requestPayload = options?.estimateTraffic ? { ...payload, estimateTraffic: true } : payload;
2407
+ return this.sendRequest("run_transaction" /* RUN_TRANSACTION */, { ...requestPayload, execution_mode: "wait" }, options);
2403
2408
  }
2404
2409
  async transfer(recipient, amount, instrument, options) {
2405
2410
  const amountStr = typeof amount === "number" ? amount.toString() : amount;
2406
- const { requestedAt, executeBefore, requestTimeout } = options || {};
2411
+ const { requestedAt, executeBefore, requestTimeout, estimateTraffic, memo } = options || {};
2407
2412
  const message = options?.message;
2408
2413
  const resolveDate = (value, fallbackMs) => {
2409
2414
  if (value instanceof Date) {
@@ -2429,6 +2434,9 @@ class Provider {
2429
2434
  requested_at: requestedAtIso,
2430
2435
  execute_before: executeBeforeIso
2431
2436
  };
2437
+ if (memo) {
2438
+ transferRequest.memo = memo;
2439
+ }
2432
2440
  const preparedPayload = await this.connection.prepareTransfer(this.auth_token, transferRequest);
2433
2441
  const submitFn = options?.executionMode === "wait" ? this.submitAndWaitForTransaction.bind(this) : this.submitTransaction.bind(this);
2434
2442
  return submitFn({
@@ -2438,7 +2446,7 @@ class Provider {
2438
2446
  actAs: preparedPayload.actAs,
2439
2447
  readAs: preparedPayload.readAs,
2440
2448
  synchronizerId: preparedPayload.synchronizerId
2441
- }, { requestTimeout, message });
2449
+ }, { requestTimeout, message, estimateTraffic });
2442
2450
  }
2443
2451
  async signMessage(message) {
2444
2452
  return this.sendRequest("sign_raw_message" /* SIGN_RAW_MESSAGE */, message);
@@ -2950,28 +2958,31 @@ class LoopSDK {
2950
2958
  .loop-connect {
2951
2959
  position: fixed;
2952
2960
  inset: 0;
2953
- background: oklch(0.222 0 0 / 0.85);
2961
+ background: rgba(0, 0, 0, 0.85);
2954
2962
  backdrop-filter: blur(8px);
2955
2963
  display: flex;
2956
2964
  justify-content: center;
2957
2965
  align-items: center;
2958
2966
  z-index: 10000;
2959
- font-family: system-ui, -apple-system, sans-serif;
2967
+ font-family: "Inter", system-ui, -apple-system, sans-serif;
2960
2968
  animation: fadeIn 0.2s ease-out;
2961
2969
  }
2962
2970
  .loop-connect dialog {
2963
2971
  position: relative;
2964
2972
  overflow: hidden;
2965
- background: oklch(0.253 0.008 274.6);
2966
- box-shadow: 0 4px 24px oklch(0 0 0 / 0.1);
2967
- border: 1px solid oklch(0.41 0.01 278.4);
2968
- border-radius: 32px;
2969
- padding: 24px;
2973
+ background: #080808;
2974
+ box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.5);
2975
+ border-radius: 40px;
2976
+ border: none;
2977
+ width: 340px;
2978
+ height: 534px;
2979
+ box-sizing: border-box;
2980
+ padding: 32px;
2970
2981
  display: flex;
2971
2982
  flex-direction: column;
2972
2983
  align-items: center;
2973
- gap: 16px;
2974
- color: oklch(0.975 0.005 280);
2984
+ gap: 0;
2985
+ color: #ffffff;
2975
2986
  }
2976
2987
  .loop-connect .bg-logo {
2977
2988
  position: absolute;
@@ -2983,56 +2994,89 @@ class LoopSDK {
2983
2994
  pointer-events: none;
2984
2995
  }
2985
2996
  .loop-connect h3 {
2997
+ position: absolute;
2998
+ top: 32px;
2999
+ left: 32px;
3000
+ right: 32px;
2986
3001
  margin: 0;
2987
3002
  font-size: 18px;
2988
- font-weight: 600;
2989
- letter-spacing: -0.015em;
3003
+ font-weight: 700;
3004
+ line-height: 27px;
3005
+ letter-spacing: -0.45px;
3006
+ text-align: center;
2990
3007
  }
2991
3008
  .loop-connect figure {
3009
+ position: absolute;
3010
+ top: 91px;
3011
+ left: 32px;
3012
+ width: 276px;
3013
+ height: 276px;
2992
3014
  margin: 0;
2993
- background: oklch(1 0 0);
2994
- padding: 8px;
2995
- border-radius: 24px;
3015
+ background: #ffffff;
3016
+ padding: 20px;
3017
+ border-radius: 8px;
2996
3018
  display: flex;
2997
3019
  justify-content: center;
2998
- border: 2px solid oklch(0.41 0.01 278.4);
2999
- box-shadow: 0 4px 24px oklch(0 0 0 / 0.1);
3020
+ border: none;
3021
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
3022
+ box-sizing: border-box;
3000
3023
  }
3001
3024
  .loop-connect img {
3002
3025
  display: block;
3003
- width: 225px;
3004
- height: 225px;
3026
+ width: 236px;
3027
+ height: 236px;
3028
+ object-fit: contain;
3029
+ border-radius: 12px;
3005
3030
  }
3006
3031
  .loop-connect .divider {
3007
- width: 100%;
3032
+ position: absolute;
3033
+ top: 399px;
3034
+ left: 36px;
3035
+ right: 36px;
3036
+ width: auto;
3008
3037
  display: flex;
3009
3038
  align-items: center;
3010
- gap: 16px;
3011
- color: oklch(0.554 0.012 280.3);
3012
- font-size: 13px;
3013
- font-weight: 600;
3039
+ justify-content: center;
3040
+ gap: 12px;
3041
+ color: #64748b;
3042
+ font-size: 11px;
3043
+ font-weight: 700;
3044
+ letter-spacing: 0.15em;
3045
+ text-transform: uppercase;
3046
+ text-align: center;
3014
3047
  }
3015
3048
  .loop-connect .divider::before,
3016
3049
  .loop-connect .divider::after {
3017
3050
  content: "";
3018
3051
  flex: 1;
3019
3052
  height: 1px;
3020
- background: oklch(0.45 0.01 278);
3053
+ background: #1e293b;
3021
3054
  }
3022
3055
  .loop-connect button {
3023
- background: oklch(0.976 0.101 112.3);
3024
- border: 1px solid oklch(0.82 0.16 110);
3025
- color: oklch(0.222 0 0);
3026
- padding: 16px 32px;
3027
- border-radius: 24px;
3056
+ position: absolute;
3057
+ top: 447.5px;
3058
+ left: 32px;
3059
+ right: 32px;
3060
+ background: #f2ff96;
3061
+ border: none;
3062
+ color: #0f172a;
3063
+ text-align: center;
3064
+ font-family: "Inter", system-ui, -apple-system, sans-serif;
3065
+ font-style: normal;
3066
+ padding: 0 24px;
3067
+ border-radius: 8px;
3028
3068
  font-size: 15px;
3029
3069
  font-weight: 600;
3070
+ line-height: 22.5px;
3030
3071
  cursor: pointer;
3031
3072
  transition: all 0.2s ease;
3032
- width: 100%;
3073
+ width: auto;
3074
+ height: 54.5px;
3075
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2),
3076
+ 0 4px 6px -4px rgba(0, 0, 0, 0.2);
3033
3077
  }
3034
3078
  .loop-connect button:hover {
3035
- background: oklch(0.98 0.105 112.5);
3079
+ background: #f6ffb4;
3036
3080
  }
3037
3081
  @keyframes fadeIn {
3038
3082
  from { opacity: 0; }
@@ -3043,7 +3087,7 @@ class LoopSDK {
3043
3087
  }
3044
3088
  showQrCode(url) {
3045
3089
  this.injectModalStyles();
3046
- import_qrcode.default.toDataURL(url, (err, dataUrl) => {
3090
+ import_qrcode.default.toDataURL(url, { margin: 0 }, (err, dataUrl) => {
3047
3091
  if (err) {
3048
3092
  console.error("Failed to generate QR code", err);
3049
3093
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fivenorth/loop-sdk",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "author": "support@fivenorth.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",