@elisym/sdk 0.10.1 → 0.10.3

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/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Address, TransactionSigner, Rpc, SolanaRpcApi } from '@solana/kit';
2
2
  import { Filter, Event } from 'nostr-tools';
3
- import { A as Asset } from './assets-CMf-v55Z.cjs';
4
- export { C as Chain, K as KNOWN_ASSETS, N as NATIVE_SOL, U as USDC_SOLANA_DEVNET, a as assetByKey, b as assetKey, f as formatAssetAmount, p as parseAssetAmount, r as resolveAssetFromPaymentRequest, c as resolveKnownAsset } from './assets-CMf-v55Z.cjs';
3
+ import { A as Asset } from './assets-C-nzSYD4.cjs';
4
+ export { C as Chain, K as KNOWN_ASSETS, N as NATIVE_SOL, U as USDC_SOLANA_DEVNET, a as assetByKey, b as assetKey, f as formatAssetAmount, p as parseAssetAmount, r as resolveAssetFromPaymentRequest, c as resolveKnownAsset } from './assets-C-nzSYD4.cjs';
5
5
  import { z } from 'zod';
6
6
  export { G as GlobalConfig, a as GlobalConfigSchema, S as SessionSpendLimitEntry, b as SessionSpendLimitEntrySchema } from './global-schema-CddHP2nk.cjs';
7
7
 
@@ -73,6 +73,7 @@ interface Agent {
73
73
  /** Count of all rated feedback events targeting this agent (last 30 days). */
74
74
  totalRatingCount?: number;
75
75
  picture?: string;
76
+ banner?: string;
76
77
  name?: string;
77
78
  about?: string;
78
79
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Address, TransactionSigner, Rpc, SolanaRpcApi } from '@solana/kit';
2
2
  import { Filter, Event } from 'nostr-tools';
3
- import { A as Asset } from './assets-CMf-v55Z.js';
4
- export { C as Chain, K as KNOWN_ASSETS, N as NATIVE_SOL, U as USDC_SOLANA_DEVNET, a as assetByKey, b as assetKey, f as formatAssetAmount, p as parseAssetAmount, r as resolveAssetFromPaymentRequest, c as resolveKnownAsset } from './assets-CMf-v55Z.js';
3
+ import { A as Asset } from './assets-C-nzSYD4.js';
4
+ export { C as Chain, K as KNOWN_ASSETS, N as NATIVE_SOL, U as USDC_SOLANA_DEVNET, a as assetByKey, b as assetKey, f as formatAssetAmount, p as parseAssetAmount, r as resolveAssetFromPaymentRequest, c as resolveKnownAsset } from './assets-C-nzSYD4.js';
5
5
  import { z } from 'zod';
6
6
  export { G as GlobalConfig, a as GlobalConfigSchema, S as SessionSpendLimitEntry, b as SessionSpendLimitEntrySchema } from './global-schema-CddHP2nk.js';
7
7
 
@@ -73,6 +73,7 @@ interface Agent {
73
73
  /** Count of all rated feedback events targeting this agent (last 30 days). */
74
74
  totalRatingCount?: number;
75
75
  picture?: string;
76
+ banner?: string;
76
77
  name?: string;
77
78
  about?: string;
78
79
  }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getTransferSolInstruction } from '@solana-program/system';
2
2
  import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS, getCreateAssociatedTokenIdempotentInstruction, ASSOCIATED_TOKEN_PROGRAM_ADDRESS, getTransferCheckedInstruction } from '@solana-program/token';
3
3
  import { pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageComputeUnitLimit, setTransactionMessageComputeUnitPrice, appendTransactionMessageInstructions, signTransactionMessageWithSigners, address, AccountRole, isAddress, getProgramDerivedAddress, assertAccountExists, getAddressDecoder, fetchEncodedAccount, decodeAccount, getStructDecoder, fixDecoderSize, getBytesDecoder, getU8Decoder, getOptionDecoder, getU16Decoder, getBooleanDecoder, getI64Decoder } from '@solana/kit';
4
- import Decimal2 from 'decimal.js-light';
4
+ import Decimal3 from 'decimal.js-light';
5
5
  import { z } from 'zod';
6
6
  import { verifyEvent, finalizeEvent, getPublicKey, nip19, generateSecretKey, SimplePool } from 'nostr-tools';
7
7
  import * as nip44 from 'nostr-tools/nip44';
@@ -151,8 +151,6 @@ async function getProtocolConfig(rpc, programId, options) {
151
151
  );
152
152
  }
153
153
  }
154
-
155
- // src/payment/assets.ts
156
154
  var NATIVE_SOL = {
157
155
  chain: "solana",
158
156
  token: "sol",
@@ -233,16 +231,10 @@ function parseAssetAmount(asset, human) {
233
231
  }
234
232
  return raw;
235
233
  }
234
+ var FormatDecimal = Decimal3.clone({ toExpNeg: -100, toExpPos: 100, precision: 50 });
236
235
  function formatAssetAmount(asset, raw) {
237
- const sign = raw < 0n ? "-" : "";
238
- const abs = raw < 0n ? -raw : raw;
239
- const unit = 10n ** BigInt(asset.decimals);
240
- const whole = abs / unit;
241
- const frac = abs % unit;
242
- if (asset.decimals === 0) {
243
- return `${sign}${whole} ${asset.symbol}`;
244
- }
245
- return `${sign}${whole}.${frac.toString().padStart(asset.decimals, "0")} ${asset.symbol}`;
236
+ const value = new FormatDecimal(raw.toString()).div(new FormatDecimal(10).pow(asset.decimals));
237
+ return `${value.toString()} ${asset.symbol}`;
246
238
  }
247
239
  var BPS_DENOMINATOR = 1e4;
248
240
  function assertLamports(value, field) {
@@ -260,7 +252,7 @@ function calculateProtocolFee(amount, feeBps) {
260
252
  if (amount === 0 || feeBps === 0) {
261
253
  return 0;
262
254
  }
263
- return new Decimal2(amount).mul(feeBps).div(BPS_DENOMINATOR).toDecimalPlaces(0, Decimal2.ROUND_CEIL).toNumber();
255
+ return new Decimal3(amount).mul(feeBps).div(BPS_DENOMINATOR).toDecimalPlaces(0, Decimal3.ROUND_CEIL).toNumber();
264
256
  }
265
257
  function validateExpiry(createdAt, expirySecs) {
266
258
  if (!Number.isInteger(createdAt) || createdAt <= 0) {
@@ -1199,6 +1191,9 @@ var DiscoveryService = class {
1199
1191
  if (typeof meta.picture === "string") {
1200
1192
  agent.picture = meta.picture;
1201
1193
  }
1194
+ if (typeof meta.banner === "string") {
1195
+ agent.banner = meta.banner;
1196
+ }
1202
1197
  if (typeof meta.name === "string") {
1203
1198
  agent.name = meta.name;
1204
1199
  }
@@ -2891,7 +2886,7 @@ var GlobalConfigSchema = z.object({
2891
2886
  session_spend_limits: z.array(SessionSpendLimitEntrySchema).max(16).optional()
2892
2887
  }).strict();
2893
2888
  function formatSol(lamports) {
2894
- const sol = new Decimal2(lamports).div(LAMPORTS_PER_SOL);
2889
+ const sol = new Decimal3(lamports).div(LAMPORTS_PER_SOL);
2895
2890
  if (sol.gte(1e6)) {
2896
2891
  return `${sol.idiv(1e6)}m SOL`;
2897
2892
  }
@@ -2905,12 +2900,12 @@ function compactSol(sol) {
2905
2900
  return "0";
2906
2901
  }
2907
2902
  if (sol.gte(1e3)) {
2908
- return sol.toDecimalPlaces(0, Decimal2.ROUND_FLOOR).toString();
2903
+ return sol.toDecimalPlaces(0, Decimal3.ROUND_FLOOR).toString();
2909
2904
  }
2910
2905
  const maxFrac = 9;
2911
2906
  for (let d = 1; d <= maxFrac; d++) {
2912
2907
  const s = sol.toFixed(d);
2913
- if (new Decimal2(s).eq(sol)) {
2908
+ if (new Decimal3(s).eq(sol)) {
2914
2909
  return s.replace(/0+$/, "").replace(/\.$/, "");
2915
2910
  }
2916
2911
  }