@aboutcircles/sdk-rpc 0.1.57 → 0.1.58-rc.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/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { CirclesRpc } from './rpc.js';
2
2
  export { RpcClient } from './client.js';
3
- export { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, } from './methods/index.js';
3
+ export { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, AffiliateMethods, } from './methods/index.js';
4
4
  export type { TransactionHistoryRow, SearchResultProfile, GroupTokenHolderRow, CursorColumn, FlexiblePagedResult, } from './types.js';
5
5
  export type { TrustRelationType, AggregatedTrustRelation, TransferDataRow } from '@aboutcircles/sdk-types';
6
+ export type { AffiliateGroupRow, AffiliateGroupListResponse, AffiliateGroupMemberRow } from '@aboutcircles/sdk-types';
6
7
  export { RpcError } from './errors.js';
7
8
  export type { RpcErrorSource } from './errors.js';
8
9
  export { normalizeAddress, normalizeAddresses, parseStringsToBigInt } from './utils.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG3G,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGxF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EACL,UAAU,EACV,aAAa,EACb,2BAA2B,EAC3B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3G,YAAY,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGtH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGxF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EACL,UAAU,EACV,aAAa,EACb,2BAA2B,EAC3B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function c(J){return J&&typeof J==="object"&&typeof J.$event==="string"&&typeof J.blockNumber==="number"&&typeof J.transactionIndex==="number"&&typeof J.logIndex==="number"}var l=(J)=>BigInt(J),I=(J)=>parseInt(J,16),OJ=(J)=>{if(J.startsWith("0x"))J=J.slice(2);if(J.length%2!==0)throw Error("Invalid hex string");let Z=new Uint8Array(J.length/2);for(let $=0;$<J.length;$+=2)Z[$/2]=parseInt(J.substr($,2),16);return Z};function DJ(J,Z){if(typeof Z==="string"&&Z.startsWith("0x")){let $=Z.slice(2);if($.length===40)return Z;if($.length===64){if(J.toLowerCase().includes("digest")||J.toLowerCase().includes("data")||J.toLowerCase().includes("bytes"))return OJ(Z);try{return l(Z)}catch{return Z}}try{let Y=I(Z);if(Y<Number.MAX_SAFE_INTEGER)return Y;return l(Z)}catch{return Z}}if(Z==="true")return!0;if(Z==="false")return!1;return Z}function b(J){let{event:Z,values:$}=J,Y={$event:Z,blockNumber:$.blockNumber?I($.blockNumber):0,timestamp:$.timestamp?I($.timestamp):void 0,transactionIndex:$.transactionIndex?I($.transactionIndex):0,logIndex:$.logIndex?I($.logIndex):0,transactionHash:$.transactionHash};for(let[W,G]of Object.entries($)){if(["blockNumber","timestamp","transactionIndex","logIndex","transactionHash"].includes(W))continue;Y[W]=DJ(W,G)}return Y}function H(J){return J.map(b)}class D{_subscribers=[];subscribe(J){return this._subscribers.push(J),()=>{let Z=this._subscribers.indexOf(J);if(Z>-1)this._subscribers.splice(Z,1)}}constructor(){this._subscribers=[]}emit(J){this._subscribers.forEach((Z)=>Z(J))}static create(){let J=new D;return{property:J,emit:(Z)=>J.emit(Z)}}}class v extends Error{name;code;source;cause;context;constructor(J,Z,$){super(Z);if(this.name=J,this.code=$?.code,this.source=$?.source??"UNKNOWN",this.cause=$?.cause,this.context=$?.context,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,source:this.source,context:this.context,cause:this.cause instanceof Error?{name:this.cause.name,message:this.cause.message}:this.cause,stack:this.stack}}toString(){let J=`[${this.source}] ${this.name}: ${this.message}`;if(this.code)J+=` (Code: ${this.code})`;if(this.context)J+=`
2
- Context: ${JSON.stringify(this.context,null,2)}`;return J}}class q extends v{constructor(J,Z){super("RpcError",J,{...Z,source:Z?.source??"RPC_REQUEST"})}static connectionFailed(J,Z){return new q("Failed to connect to RPC endpoint",{code:"RPC_CONNECTION_FAILED",source:"RPC_CONNECTION",cause:Z,context:{url:J}})}static timeout(J,Z){return new q("RPC request timed out",{code:"RPC_TIMEOUT",source:"RPC_TIMEOUT",context:{method:J,timeout:Z}})}static invalidResponse(J,Z){return new q("Invalid RPC response",{code:"RPC_INVALID_RESPONSE",source:"RPC_RESPONSE",context:{method:J,response:Z}})}static fromJsonRpcError(J){return new q(J.message,{code:J.code,source:"RPC_RESPONSE",context:{data:J.data}})}static websocketError(J,Z){return new q(J,{code:"RPC_WEBSOCKET_ERROR",source:"RPC_WEBSOCKET",cause:Z})}}class k{rpcUrl;requestId=0;websocket=null;websocketConnected=!1;pendingResponses={};subscriptionListeners={};activeSubscriptions=[];reconnectAttempt=0;initialBackoff=2000;maxBackoff=120000;constructor(J){this.rpcUrl=J}async call(J,Z){this.requestId++;let $={jsonrpc:"2.0",id:this.requestId,method:J,params:Z};try{let Y=await fetch(this.rpcUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(!Y.ok)throw q.connectionFailed(this.rpcUrl,Error(`HTTP ${Y.status}: ${Y.statusText}`));let W=await Y.json();if(W.error)throw q.fromJsonRpcError(W.error);if(W.result===void 0)throw q.invalidResponse(J,W);return W.result}catch(Y){if(Y instanceof q)throw Y;throw q.connectionFailed(this.rpcUrl,Y)}}setRpcUrl(J){this.rpcUrl=J}getRpcUrl(){return this.rpcUrl}connect(){return new Promise((J,Z)=>{let $=this.rpcUrl.replace("http","ws");if($.endsWith("/"))$+="ws/subscribe";else $+="/ws/subscribe";this.websocket=new WebSocket($),this.websocket.onopen=()=>{console.log("WebSocket connected"),this.websocketConnected=!0,this.reconnectAttempt=0,J()},this.websocket.onmessage=(Y)=>{let W=JSON.parse(Y.data),{id:G,method:Q,params:M}=W;if(G!==void 0&&this.pendingResponses[G])this.pendingResponses[G].resolve(W),delete this.pendingResponses[G];if(Q==="circles_subscription"&&M?.result)Object.values(this.subscriptionListeners).forEach((F)=>{F.forEach((O)=>O(M.result))})},this.websocket.onclose=()=>{console.warn("WebSocket closed");let Y=this.websocketConnected;if(this.websocketConnected=!1,Y)this.scheduleReconnect()},this.websocket.onerror=(Y)=>{console.error("WebSocket error:",Y),this.websocketConnected=!1,Z(q.connectionFailed(this.rpcUrl,Y instanceof Error?Y:Error("WebSocket connection failed"))),this.scheduleReconnect()}})}scheduleReconnect(){let J=Math.min(this.initialBackoff*Math.pow(2,this.reconnectAttempt),this.maxBackoff),Z=J*(Math.random()*0.5),$=J+Z;console.log(`Reconnecting in ${Math.round($)}ms (attempt #${this.reconnectAttempt+1})`),this.reconnectAttempt++,setTimeout(()=>{this.reconnect()},$)}async reconnect(){if(this.websocketConnected)return;try{await this.connect(),console.log("Reconnection successful"),await this.resubscribeActive()}catch(J){console.error("Reconnection attempt failed:",J),this.scheduleReconnect()}}async resubscribeActive(){if(this.activeSubscriptions.length===0)return;let J=[...this.activeSubscriptions];this.activeSubscriptions=[];for(let Z of J)try{let $=Z.address?{address:Z.address}:{},W=(await this.sendMessage("circles_subscribe",$)).result,G=this.subscriptionListeners[Z.id];if(G)this.subscriptionListeners[W]=G,delete this.subscriptionListeners[Z.id];this.activeSubscriptions.push({id:W,address:Z.address})}catch($){console.error("Failed to re-issue circles_subscribe after reconnect:",$),this.activeSubscriptions.push(Z)}}sendMessage(J,Z,$=5000){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return Promise.reject(q.connectionFailed(this.rpcUrl));let Y=this.requestId++,W={jsonrpc:"2.0",method:J,params:Z,id:Y};return new Promise((G,Q)=>{this.pendingResponses[Y]={resolve:G,reject:Q},this.websocket.send(JSON.stringify(W)),setTimeout(()=>{if(this.pendingResponses[Y])this.pendingResponses[Y].reject(q.timeout(J,$)),delete this.pendingResponses[Y]},$)})}async subscribe(J){let Z=J?.toLowerCase();if(!this.websocketConnected)await this.connect();let $=D.create(),Y=Z?{address:Z}:{},G=(await this.sendMessage("circles_subscribe",Y)).result;if(!this.subscriptionListeners[G])this.subscriptionListeners[G]=[];return this.subscriptionListeners[G].push((Q)=>{H(Q).forEach((M)=>$.emit(M))}),this.activeSubscriptions.push({id:G,address:Z}),$.property}}var g=BigInt(4294967295),d=BigInt(32);function IJ(J,Z=!1){if(Z)return{h:Number(J&g),l:Number(J>>d&g)};return{h:Number(J>>d&g)|0,l:Number(J&g)|0}}function i(J,Z=!1){let $=J.length,Y=new Uint32Array($),W=new Uint32Array($);for(let G=0;G<$;G++){let{h:Q,l:M}=IJ(J[G],Z);[Y[G],W[G]]=[Q,M]}return[Y,W]}var n=(J,Z,$)=>J<<$|Z>>>32-$,o=(J,Z,$)=>Z<<$|J>>>32-$,t=(J,Z,$)=>Z<<$-32|J>>>64-$,a=(J,Z,$)=>J<<$-32|Z>>>64-$;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function jJ(J){return J instanceof Uint8Array||ArrayBuffer.isView(J)&&J.constructor.name==="Uint8Array"}function f(J,Z=""){if(!Number.isSafeInteger(J)||J<0){let $=Z&&`"${Z}" `;throw Error(`${$}expected integer >= 0, got ${J}`)}}function A(J,Z,$=""){let Y=jJ(J),W=J?.length,G=Z!==void 0;if(!Y||G&&W!==Z){let Q=$&&`"${$}" `,M=G?` of length ${Z}`:"",F=Y?`length=${W}`:`type=${typeof J}`;throw Error(Q+"expected Uint8Array"+M+", got "+F)}return J}function y(J,Z=!0){if(J.destroyed)throw Error("Hash instance has been destroyed");if(Z&&J.finished)throw Error("Hash#digest() has already been called")}function r(J,Z){A(J,void 0,"digestInto() output");let $=Z.outputLen;if(J.length<$)throw Error('"digestInto() output" expected to be of length >='+$)}function s(J){return new Uint32Array(J.buffer,J.byteOffset,Math.floor(J.byteLength/4))}function h(...J){for(let Z=0;Z<J.length;Z++)J[Z].fill(0)}var LJ=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function PJ(J){return J<<24&4278190080|J<<8&16711680|J>>>8&65280|J>>>24&255}function RJ(J){for(let Z=0;Z<J.length;Z++)J[Z]=PJ(J[Z]);return J}var p=LJ?(J)=>J:RJ;function e(J,Z={}){let $=(W,G)=>J(G).update(W).digest(),Y=J(void 0);return $.outputLen=Y.outputLen,$.blockLen=Y.blockLen,$.create=(W)=>J(W),Object.assign($,Z),Object.freeze($)}var _J=BigInt(0),j=BigInt(1),TJ=BigInt(2),zJ=BigInt(7),CJ=BigInt(256),EJ=BigInt(113),$J=[],YJ=[],WJ=[];for(let J=0,Z=j,$=1,Y=0;J<24;J++){[$,Y]=[Y,(2*$+3*Y)%5],$J.push(2*(5*Y+$)),YJ.push((J+1)*(J+2)/2%64);let W=_J;for(let G=0;G<7;G++)if(Z=(Z<<j^(Z>>zJ)*EJ)%CJ,Z&TJ)W^=j<<(j<<BigInt(G))-j;WJ.push(W)}var GJ=i(WJ,!0),SJ=GJ[0],wJ=GJ[1],JJ=(J,Z,$)=>$>32?t(J,Z,$):n(J,Z,$),ZJ=(J,Z,$)=>$>32?a(J,Z,$):o(J,Z,$);function BJ(J,Z=24){let $=new Uint32Array(10);for(let Y=24-Z;Y<24;Y++){for(let Q=0;Q<10;Q++)$[Q]=J[Q]^J[Q+10]^J[Q+20]^J[Q+30]^J[Q+40];for(let Q=0;Q<10;Q+=2){let M=(Q+8)%10,F=(Q+2)%10,O=$[F],U=$[F+1],UJ=JJ(O,U,1)^$[M],NJ=ZJ(O,U,1)^$[M+1];for(let B=0;B<50;B+=10)J[Q+B]^=UJ,J[Q+B+1]^=NJ}let W=J[2],G=J[3];for(let Q=0;Q<24;Q++){let M=YJ[Q],F=JJ(W,G,M),O=ZJ(W,G,M),U=$J[Q];W=J[U],G=J[U+1],J[U]=F,J[U+1]=O}for(let Q=0;Q<50;Q+=10){for(let M=0;M<10;M++)$[M]=J[Q+M];for(let M=0;M<10;M++)J[Q+M]^=~$[(M+2)%10]&$[(M+4)%10]}J[0]^=SJ[Y],J[1]^=wJ[Y]}h($)}class m{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(J,Z,$,Y=!1,W=24){if(this.blockLen=J,this.suffix=Z,this.outputLen=$,this.enableXOF=Y,this.rounds=W,f($,"outputLen"),!(0<J&&J<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=s(this.state)}clone(){return this._cloneInto()}keccak(){p(this.state32),BJ(this.state32,this.rounds),p(this.state32),this.posOut=0,this.pos=0}update(J){y(this),A(J);let{blockLen:Z,state:$}=this,Y=J.length;for(let W=0;W<Y;){let G=Math.min(Z-this.pos,Y-W);for(let Q=0;Q<G;Q++)$[this.pos++]^=J[W++];if(this.pos===Z)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:J,suffix:Z,pos:$,blockLen:Y}=this;if(J[$]^=Z,(Z&128)!==0&&$===Y-1)this.keccak();J[Y-1]^=128,this.keccak()}writeInto(J){y(this,!1),A(J),this.finish();let Z=this.state,{blockLen:$}=this;for(let Y=0,W=J.length;Y<W;){if(this.posOut>=$)this.keccak();let G=Math.min($-this.posOut,W-Y);J.set(Z.subarray(this.posOut,this.posOut+G),Y),this.posOut+=G,Y+=G}return J}xofInto(J){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(J)}xof(J){return f(J),this.xofInto(new Uint8Array(J))}digestInto(J){if(r(J,this),this.finished)throw Error("digest() was already called");return this.writeInto(J),this.destroy(),J}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,h(this.state)}_cloneInto(J){let{blockLen:Z,suffix:$,outputLen:Y,rounds:W,enableXOF:G}=this;return J||=new m(Z,$,Y,G,W),J.state32.set(this.state32),J.pos=this.pos,J.posOut=this.posOut,J.finished=this.finished,J.rounds=W,J.suffix=$,J.outputLen=Y,J.enableXOF=G,J.destroyed=this.destroyed,J}}var HJ=(J,Z,$,Y={})=>e(()=>new m(Z,J,$),Y);var QJ=HJ(1,136,32);var VJ=[];for(let J=0;J<256;J++)VJ[J]=J.toString(16).padStart(2,"0");function KJ(J){let Z="0x";for(let $=0;$<J.length;$++)Z+=VJ[J[$]];return Z}function MJ(J){let Z=J.toLowerCase().replace("0x",""),$=KJ(QJ(new TextEncoder().encode(Z))).slice(2),Y="0x";for(let W=0;W<Z.length;W++)Y+=parseInt($[W],16)>=8?Z[W].toUpperCase():Z[W];return Y}function V(J){return J.toLowerCase()}function kJ(J){return J.map((Z)=>V(Z))}function gJ(J){return MJ(J)}function AJ(J){if(typeof J!=="string")return!1;let Z=J.replace("0x","");return Z.length===40&&/^[0-9a-fA-F]{40}$/.test(Z)}function K(J){if(J===null||J===void 0)return J;if(AJ(J))return gJ(J);if(Array.isArray(J))return J.map((Z)=>K(Z));if(typeof J==="object"&&J!==null){let Z={};for(let $ in J)if(Object.prototype.hasOwnProperty.call(J,$))Z[$]=K(J[$]);return Z}return J}function qJ(J){return{Source:V(J.from),Sink:V(J.to),TargetFlow:J.targetFlow.toString(),WithWrap:J.useWrappedBalances,FromTokens:J.fromTokens?.map(V),ToTokens:J.toTokens?.map(V),ExcludedFromTokens:J.excludeFromTokens?.map(V),ExcludedToTokens:J.excludeToTokens?.map(V),SimulatedBalances:J.simulatedBalances?.map((Z)=>({Holder:V(Z.holder),Token:V(Z.token),Amount:Z.amount.toString(),IsWrapped:Z.isWrapped,IsStatic:Z.isStatic})),SimulatedTrusts:J.simulatedTrusts?.map((Z)=>({Truster:V(Z.truster),Trustee:V(Z.trustee)})),MaxTransfers:J.maxTransfers}}function X(J){let Z={};for(let $ in J){let Y=J[$];if(Y===null||Y===void 0)Z[$]=Y;else if(typeof Y==="string"&&/^\d+$/.test(Y))Z[$]=BigInt(Y);else if(typeof Y==="object"&&!Array.isArray(Y))Z[$]=X(Y);else if(Array.isArray(Y))Z[$]=Y.map((W)=>typeof W==="object"&&W!==null?X(W):W);else Z[$]=Y}return Z}var QZ=BigInt(96)*BigInt(1000000000000000000),FJ=BigInt("9999999999999999999999999999999999999");class L{client;constructor(J){this.client=J}async findPath(J){let Z=qJ(J),$=await this.client.call("circlesV2_findPath",[Z]),Y=X($);return K(Y)}async findMaxFlow(J){let Z=await this.findPath({...J,targetFlow:FJ});return BigInt(Z.maxFlow)}}class P{client;constructor(J){this.client=J}async query(J){let Z=await this.client.call("circles_query",[J]),{columns:$,rows:Y}=Z,W=Y.map((G)=>{let Q={};return $.forEach((M,F)=>{Q[M]=G[F]}),Q});return K(W)}async tables(){return this.client.call("circles_tables",[])}async events(J=null,Z=null,$=null,Y=null,W=null,G=!1,Q=100,M=null){let F=await this.client.call("circles_events_paginated",[J,Z,$,Y,W,G,Q,M]);return{events:K(F.events),hasMore:F.hasMore,nextCursor:F.nextCursor}}}var xJ=[{name:"blockNumber",sortOrder:"DESC"},{name:"transactionIndex",sortOrder:"DESC"},{name:"logIndex",sortOrder:"DESC"}];class N{params;client;rowTransformer;cursorColumns;orderColumns;get currentPage(){return this._currentPage}_currentPage;constructor(J,Z,$){this.client=J,this.params=Z,this.rowTransformer=$||Z.rowTransformer,this.orderColumns=Z.orderColumns,this.cursorColumns=Z.cursorColumns||this.buildEventCursorColumns()}buildEventCursorColumns(){let J=xJ.map((Z)=>({...Z,sortOrder:this.params.sortOrder}));if(this.params.table==="TransferBatch")J.push({name:"batchIndex",sortOrder:this.params.sortOrder});return J}buildOrderBy(){if(this.orderColumns&&this.orderColumns.length>0)return this.orderColumns;return this.cursorColumns.map((J)=>({Column:J.name,SortOrder:J.sortOrder}))}rowsToObjects(J){let{columns:Z,rows:$}=J;return $.map((Y)=>{let W={};return Z.forEach((G,Q)=>{W[G]=Y[Q]}),this.rowTransformer?this.rowTransformer(W):W})}async queryNextPage(){let J={Namespace:this.params.namespace,Table:this.params.table,Columns:this.params.columns,Filter:this.params.filter||[],Order:this.buildOrderBy(),Limit:this.params.limit},Z=this._currentPage?.nextCursor?[J,this._currentPage.nextCursor]:[J],$=await this.client.call("circles_paginated_query",Z),Y=this.rowsToObjects($);return this._currentPage={limit:this.params.limit,size:Y.length,sortOrder:this.params.sortOrder,hasMore:$.hasMore,nextCursor:$.nextCursor??void 0,results:Y},Y.length>0}reset(){this._currentPage=void 0}}class R{client;constructor(J){this.client=J}transformQueryResponse(J){let{columns:Z,rows:$}=J;return $.map((Y)=>{let W={};return Z.forEach((G,Q)=>{W[G]=Y[Q]}),W})}async getCommonTrust(J,Z){let $=await this.client.call("circles_getCommonTrust",[V(J),V(Z)]);return K($)}getTrustRelations(J,Z=100,$="DESC"){let Y=V(J),W=[{Type:"Conjunction",ConjunctionType:"And",Predicates:[{Type:"FilterPredicate",FilterType:"Equals",Column:"version",Value:2},{Type:"Conjunction",ConjunctionType:"Or",Predicates:[{Type:"FilterPredicate",FilterType:"Equals",Column:"trustee",Value:Y},{Type:"FilterPredicate",FilterType:"Equals",Column:"truster",Value:Y}]}]}];return new N(this.client,{namespace:"V_Crc",table:"TrustRelations",sortOrder:$,columns:["blockNumber","timestamp","transactionIndex","logIndex","transactionHash","version","trustee","truster","expiryTime"],filter:W,limit:Z},(G)=>K(G))}async getAggregatedTrustRelations(J){let Z=V(J),$=await this.client.call("circles_getAggregatedTrustRelations",[Z]);return K($)}async getTrustedBy(J){let Z=V(J),Y=(await this.getAggregatedTrustRelations(Z)).filter((W)=>W.relation==="trustedBy");return K(Y)}async getTrusts(J){let Z=V(J),Y=(await this.getAggregatedTrustRelations(Z)).filter((W)=>W.relation==="trusts");return K(Y)}async getMutualTrusts(J){let Z=V(J),Y=(await this.getAggregatedTrustRelations(Z)).filter((W)=>W.relation==="mutuallyTrusts");return K(Y)}async getTrustNetworkSummary(J,Z=2){return this.client.call("circles_getTrustNetworkSummary",[V(J),Z])}async getAggregatedTrustRelationsEnriched(J){return this.client.call("circles_getAggregatedTrustRelationsEnriched",[V(J)])}async getValidInviters(J,Z){let $=[V(J)];if(Z)$.push(Z);return this.client.call("circles_getValidInviters",$)}}class u{static ONE_64=1n<<64n;static GAMMA_64=18443079296116538654n;static BETA_64=18450409579521241655n;static SECONDS_PER_DAY=86400n;static INFLATION_DAY_ZERO_UNIX=1602720000n;static ATTO_FACTOR=1000000000000000000n;static FACTOR_1E12=1000000000000n;static V1_ACCURACY=100000000n;static V1_INFLATION_PCT_NUM=107n;static V1_INFLATION_PCT_DEN=100n;static PERIOD_SEC=31556952n;static mul64(J,Z){return J*Z>>64n}static mulU(J,Z){return J*Z>>64n}static pow64(J,Z){let $=J,Y=Z,W=this.ONE_64;while(Y>0n){if((Y&1n)===1n)W=this.mul64(W,$);$=this.mul64($,$),Y>>=1n}return W}static ONE_36=1000000000000000000000000000000000000000n;static GAMMA_36=999801332008598957430613406568191166n;static BETA_36=1000198707468214629156271489013303962n;static mul36(J,Z){return J*Z/this.ONE_36}static pow36(J,Z){let $=this.ONE_36,Y=J,W=Z;while(W>0n){if((W&1n)===1n)$=this.mul36($,Y);Y=this.mul36(Y,Y),W>>=1n}return $}static attoCirclesToCircles(J){if(J===0n)return 0;let Z=J/this.ATTO_FACTOR,$=J%this.ATTO_FACTOR,Y=BigInt(Number.MAX_SAFE_INTEGER);if(Z>Y||Z<-Y)throw RangeError("Atto value’s integer component exceeds JS double precision.");return Number(Z)+Number($)/Number(this.ATTO_FACTOR)}static circlesToAttoCircles(J){return BigInt(Math.trunc(J*Number(this.ATTO_FACTOR)))}static inflationaryToDemurrage(J,Z){return this.mulU(this.pow64(this.GAMMA_64,Z),J)}static demurrageToInflationary(J,Z){return this.mulU(this.pow64(this.BETA_64,Z),J)}static dayFromTimestamp(J){return(J-this.INFLATION_DAY_ZERO_UNIX)/this.SECONDS_PER_DAY}static attoCirclesToAttoStaticCircles(J,Z=BigInt(Math.floor(Date.now()/1000))){return this.demurrageToInflationary(J,this.dayFromTimestamp(Z))}static attoStaticCirclesToAttoCircles(J,Z=BigInt(Math.floor(Date.now()/1000))){return this.inflationaryToDemurrage(J,this.dayFromTimestamp(Z))}static inflationaryToDemurrageExact(J,Z){let $=this.pow36(this.GAMMA_36,Z);return J*$/this.ONE_36}static demurrageToInflationaryExact(J,Z){let $=this.pow36(this.BETA_36,Z);return J*$/this.ONE_36}static attoCirclesToAttoStaticCirclesExact(J,Z=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Z);return this.demurrageToInflationaryExact(J,$)}static attoStaticCirclesToAttoCirclesExact(J,Z=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Z);return this.inflationaryToDemurrageExact(J,$)}static truncateToInt64(J){let Z=J/this.FACTOR_1E12,$=9223372036854775807n;return Z>$?$:Z}static blowUpToBigInt(J){return J*this.FACTOR_1E12}static truncateToSixDecimals(J){return this.blowUpToBigInt(this.truncateToInt64(J))}static v1InflateFactor(J){if(J===0n)return this.V1_ACCURACY;return this.V1_ACCURACY*this.V1_INFLATION_PCT_NUM**J/this.V1_INFLATION_PCT_DEN**J}static attoCrcToAttoCircles(J,Z){let $=Z-this.INFLATION_DAY_ZERO_UNIX,Y=$/this.PERIOD_SEC,W=$%this.PERIOD_SEC,G=this.v1InflateFactor(Y),Q=this.v1InflateFactor(Y+1n);return this.v1ToDemurrage(J,G,Q,W,this.PERIOD_SEC)}static attoCirclesToAttoCrc(J,Z){let $=Z-this.INFLATION_DAY_ZERO_UNIX,Y=$/this.PERIOD_SEC,W=$%this.PERIOD_SEC,G=this.v1InflateFactor(Y),Q=this.v1InflateFactor(Y+1n),M=G*(this.PERIOD_SEC-W)+Q*W;return J*3n*this.V1_ACCURACY*this.PERIOD_SEC/M}static v1ToDemurrage(J,Z,$,Y,W){let G=Z*(W-Y)+$*Y;return J*3n*this.V1_ACCURACY*W/G}}class _{client;constructor(J){this.client=J}async getTotalBalance(J,Z=!0){let $=await this.client.call("circlesV2_getTotalBalance",[V(J),Z]);return u.circlesToAttoCircles($)}async getTokenBalances(J){let $=(await this.client.call("circles_getTokenBalances",[V(J)])).map((Y)=>X(Y));return K($)}}class T{client;constructor(J){this.client=J}async getAvatarInfo(J){let Z=await this.getAvatarInfoBatch([J]);return Z.length>0?Z[0]:void 0}async getAvatarInfoBatch(J){if(J.length===0)return[];let Z=J.map((Y)=>V(Y)),$=await this.client.call("circles_getAvatarInfoBatch",[Z]);return K($)}async getNetworkSnapshot(){let J=await this.client.call("circles_getNetworkSnapshot",[]);return K(J)}}class z{client;constructor(J){this.client=J}async getProfileByCid(J){return this.client.call("circles_getProfileByCid",[J])}async getProfileByCidBatch(J){return this.client.call("circles_getProfileByCidBatch",[J])}async getProfileByAddress(J){return this.client.call("circles_getProfileByAddress",[V(J)])}async getProfileByAddressBatch(J){return this.client.call("circles_getProfileByAddressBatch",[J.map((Z)=>Z===null?null:V(Z))])}async searchProfiles(J,Z=10,$=0,Y){return this.client.call("circles_searchProfiles",[J.toLowerCase(),Z,$,Y])}async searchByAddressOrName(J,Z=10,$,Y){return this.client.call("circles_searchProfileByAddressOrName",Y?[J,Z,$??null,Y]:[J,Z,$??null])}async getProfileView(J){return this.client.call("circles_getProfileView",[V(J)])}}class C{client;constructor(J){this.client=J}async getTokenInfo(J){let Z=await this.getTokenInfoBatch([J]);return Z.length>0?Z[0]:void 0}async getTokenInfoBatch(J){if(J.length===0)return[];let Z=J.map((W)=>V(W)),Y=(await this.client.call("circles_getTokenInfoBatch",[Z])).map((W)=>X(W));return K(Y)}async getTokenHolders(J,Z=100,$){let Y=await this.client.call("circles_getTokenHolders",[V(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}}class E{client;constructor(J){this.client=J}async getInvitationOrigin(J){let Z=V(J),$=await this.client.call("circles_getInvitationOrigin",[Z]);return $?K($):null}async getInvitedBy(J){let Z=await this.getInvitationOrigin(J);if(Z?.inviter)return K(Z.inviter);return}async getTrustInvitations(J,Z){let $=V(J),Y=await this.client.call("circles_getTrustInvitations",Z?[$,Z]:[$]);return K(Y)}async getInvitations(J,Z){let Y=(await this.getValidInviters(J,Z)).results.map((W)=>W.avatarInfo).filter((W)=>W!==void 0&&W!==null);return K(Y)}async getValidInviters(J,Z){let $=V(J),Y=await this.client.call("circles_getValidInviters",Z?[$,Z]:[$]);return K(Y)}async getInvitationsFrom(J,Z=!1){let $=V(J),Y=await this.client.call("circles_getInvitationsFrom",[$,Z]);return K(Y)}async getEscrowInvitations(J){let Z=V(J),$=await this.client.call("circles_getEscrowInvitations",[Z]);return K($)}async getAtScaleInvitations(J){let Z=V(J),$=await this.client.call("circles_getAtScaleInvitations",[Z]);return K($)}async getAllInvitations(J,Z){let $=V(J),Y=await this.client.call("circles_getAllInvitations",Z?[$,Z]:[$]);return K(Y)}}class S{client;constructor(J){this.client=J}async getTransactionHistory(J,Z=50,$){let Y=await this.client.call("circles_getTransactionHistory",[V(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}async getTransactionHistoryEnriched(J,Z=0,$=null,Y=20,W){let G=await this.client.call("circles_getTransactionHistoryEnriched",[V(J),Z,$,Y,W??null]);return{hasMore:G.hasMore,nextCursor:G.nextCursor,results:K(G.results)}}async getTransferData(J,Z,$,Y,W,G=50,Q){let M=await this.client.call("circles_getTransferData",[V(J),Z??null,$?V($):null,Y??null,W??null,G,Q??null]);return{hasMore:M.hasMore,nextCursor:M.nextCursor,results:K(M.results)}}}class w{client;constructor(J){this.client=J}async findGroups(J=50,Z,$){let Y=Z?{nameStartsWith:Z.nameStartsWith,symbolStartsWith:Z.symbolStartsWith,ownerIn:Z.ownerIn?.map((Q)=>V(Q))}:void 0,W=await this.client.call("circles_findGroups",[J,Y??null,$??null]),G=K(W.results).map((Q)=>{let M=Q;if(!M.owner&&M.mint)return{...M,owner:M.mint};return M});return{hasMore:W.hasMore,nextCursor:W.nextCursor,results:G}}async getGroupMemberships(J,Z=50,$){let Y=await this.client.call("circles_getGroupMemberships",[V(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}async getGroupMembers(J,Z=100,$){let Y=await this.client.call("circles_getGroupMembers",[V(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}getGroups(J=50,Z,$="DESC"){let Y=[];if(Z){if(Z.nameStartsWith)Y.push({Type:"FilterPredicate",FilterType:"Like",Column:"name",Value:Z.nameStartsWith+"%"});if(Z.symbolStartsWith)Y.push({Type:"FilterPredicate",FilterType:"Like",Column:"symbol",Value:Z.symbolStartsWith+"%"});if(Z.groupAddressIn&&Z.groupAddressIn.length>0){let G=Z.groupAddressIn.map((Q)=>({Type:"FilterPredicate",FilterType:"Equals",Column:"group",Value:V(Q)}));if(G.length===1)Y.push(G[0]);else Y.push({Type:"Conjunction",ConjunctionType:"Or",Predicates:G})}if(Z.groupTypeIn&&Z.groupTypeIn.length>0){let G=Z.groupTypeIn.map((Q)=>({Type:"FilterPredicate",FilterType:"Equals",Column:"type",Value:Q}));if(G.length===1)Y.push(G[0]);else Y.push({Type:"Conjunction",ConjunctionType:"Or",Predicates:G})}if(Z.ownerIn&&Z.ownerIn.length>0){let G=Z.ownerIn.map((Q)=>({Type:"FilterPredicate",FilterType:"Equals",Column:"owner",Value:V(Q)}));if(G.length===1)Y.push(G[0]);else Y.push({Type:"Conjunction",ConjunctionType:"Or",Predicates:G})}if(Z.mintHandlerEquals)Y.push({Type:"FilterPredicate",FilterType:"Equals",Column:"mintHandler",Value:V(Z.mintHandlerEquals)});if(Z.treasuryEquals)Y.push({Type:"FilterPredicate",FilterType:"Equals",Column:"treasury",Value:V(Z.treasuryEquals)})}let W=Y.length>1?[{Type:"Conjunction",ConjunctionType:"And",Predicates:Y}]:Y;return new N(this.client,{namespace:"V_CrcV2",table:"Groups",sortOrder:$,columns:["blockNumber","timestamp","transactionIndex","logIndex","transactionHash","group","type","owner","mintPolicy","mintHandler","treasury","service","feeCollection","memberCount","name","symbol","cidV0Digest","erc20WrapperDemurraged","erc20WrapperStatic"],filter:W,limit:J},(G)=>K(G))}getGroupHolders(J,Z=100){let $=V(J);return new N(this.client,{namespace:"V_Crc",table:"TokenBalances",sortOrder:"DESC",columns:["blockNumber","timestamp","transactionIndex","logIndex","transactionHash","token","account","balance","lastChangedAt"],filter:[{Type:"FilterPredicate",FilterType:"Equals",Column:"token",Value:$}],limit:Z},(Y)=>K(Y))}}class x{client;constructor(J){this.client=J}async getProfileView(J){let Z=V(J);return this.client.call("circles_getProfileView",[Z])}async getTrustNetworkSummary(J,Z=2){let $=V(J);return this.client.call("circles_getTrustNetworkSummary",[$,Z])}async getAggregatedTrustRelations(J){let Z=V(J);return this.client.call("circles_getAggregatedTrustRelations",[Z])}async getValidInviters(J,Z){let $=V(J),Y=await this.client.call("circles_getValidInviters",Z?[$,Z]:[$]);return K(Y)}async getTransactionHistoryEnriched(J,Z=0,$=null,Y=50,W){let G=V(J),Q=await this.client.call("circles_getTransactionHistoryEnriched",[G,Z,$,Y,W??null]);return{hasMore:Q.hasMore,nextCursor:Q.nextCursor,results:K(Q.results)}}async searchProfileByAddressOrName(J,Z=20,$,Y){return this.client.call("circles_searchProfileByAddressOrName",Y?[J,Z,$??null,Y]:[J,Z,$??null])}}class XJ{client;_pathfinder;_query;_trust;_balance;_avatar;_profile;_token;_invitation;_transaction;_group;_sdk;constructor(J="https://rpc.aboutcircles.com/"){this.client=new k(J)}get pathfinder(){if(!this._pathfinder)this._pathfinder=new L(this.client);return this._pathfinder}get query(){if(!this._query)this._query=new P(this.client);return this._query}get trust(){if(!this._trust)this._trust=new R(this.client);return this._trust}get balance(){if(!this._balance)this._balance=new _(this.client);return this._balance}get avatar(){if(!this._avatar)this._avatar=new T(this.client);return this._avatar}get profile(){if(!this._profile)this._profile=new z(this.client);return this._profile}get token(){if(!this._token)this._token=new C(this.client);return this._token}get invitation(){if(!this._invitation)this._invitation=new E(this.client);return this._invitation}get transaction(){if(!this._transaction)this._transaction=new S(this.client);return this._transaction}get group(){if(!this._group)this._group=new w(this.client);return this._group}get sdk(){if(!this._sdk)this._sdk=new x(this.client);return this._sdk}setRpcUrl(J){this.client.setRpcUrl(J)}getRpcUrl(){return this.client.getRpcUrl()}}export{X as parseStringsToBigInt,H as parseRpcSubscriptionMessage,b as parseRpcEvent,kJ as normalizeAddresses,V as normalizeAddress,c as isCirclesEvent,R as TrustMethods,S as TransactionMethods,C as TokenMethods,q as RpcError,k as RpcClient,P as QueryMethods,z as ProfileMethods,L as PathfinderMethods,N as PagedQuery,D as Observable,E as InvitationMethods,w as GroupMethods,XJ as CirclesRpc,_ as BalanceMethods,T as AvatarMethods};
1
+ function l(J){return J&&typeof J==="object"&&typeof J.$event==="string"&&typeof J.blockNumber==="number"&&typeof J.transactionIndex==="number"&&typeof J.logIndex==="number"}var d=(J)=>BigInt(J),I=(J)=>parseInt(J,16),IJ=(J)=>{if(J.startsWith("0x"))J=J.slice(2);if(J.length%2!==0)throw Error("Invalid hex string");let Z=new Uint8Array(J.length/2);for(let $=0;$<J.length;$+=2)Z[$/2]=parseInt(J.substr($,2),16);return Z};function jJ(J,Z){if(typeof Z==="string"&&Z.startsWith("0x")){let $=Z.slice(2);if($.length===40)return Z;if($.length===64){if(J.toLowerCase().includes("digest")||J.toLowerCase().includes("data")||J.toLowerCase().includes("bytes"))return IJ(Z);try{return d(Z)}catch{return Z}}try{let Y=I(Z);if(Y<Number.MAX_SAFE_INTEGER)return Y;return d(Z)}catch{return Z}}if(Z==="true")return!0;if(Z==="false")return!1;return Z}function v(J){let{event:Z,values:$}=J,Y={$event:Z,blockNumber:$.blockNumber?I($.blockNumber):0,timestamp:$.timestamp?I($.timestamp):void 0,transactionIndex:$.transactionIndex?I($.transactionIndex):0,logIndex:$.logIndex?I($.logIndex):0,transactionHash:$.transactionHash};for(let[W,G]of Object.entries($)){if(["blockNumber","timestamp","transactionIndex","logIndex","transactionHash"].includes(W))continue;Y[W]=jJ(W,G)}return Y}function k(J){return J.map(v)}class D{_subscribers=[];subscribe(J){return this._subscribers.push(J),()=>{let Z=this._subscribers.indexOf(J);if(Z>-1)this._subscribers.splice(Z,1)}}constructor(){this._subscribers=[]}emit(J){this._subscribers.forEach((Z)=>Z(J))}static create(){let J=new D;return{property:J,emit:(Z)=>J.emit(Z)}}}class f extends Error{name;code;source;cause;context;constructor(J,Z,$){super(Z);if(this.name=J,this.code=$?.code,this.source=$?.source??"UNKNOWN",this.cause=$?.cause,this.context=$?.context,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,source:this.source,context:this.context,cause:this.cause instanceof Error?{name:this.cause.name,message:this.cause.message}:this.cause,stack:this.stack}}toString(){let J=`[${this.source}] ${this.name}: ${this.message}`;if(this.code)J+=` (Code: ${this.code})`;if(this.context)J+=`
2
+ Context: ${JSON.stringify(this.context,null,2)}`;return J}}class M extends f{constructor(J,Z){super("RpcError",J,{...Z,source:Z?.source??"RPC_REQUEST"})}static connectionFailed(J,Z){return new M("Failed to connect to RPC endpoint",{code:"RPC_CONNECTION_FAILED",source:"RPC_CONNECTION",cause:Z,context:{url:J}})}static timeout(J,Z){return new M("RPC request timed out",{code:"RPC_TIMEOUT",source:"RPC_TIMEOUT",context:{method:J,timeout:Z}})}static invalidResponse(J,Z){return new M("Invalid RPC response",{code:"RPC_INVALID_RESPONSE",source:"RPC_RESPONSE",context:{method:J,response:Z}})}static fromJsonRpcError(J){return new M(J.message,{code:J.code,source:"RPC_RESPONSE",context:{data:J.data}})}static websocketError(J,Z){return new M(J,{code:"RPC_WEBSOCKET_ERROR",source:"RPC_WEBSOCKET",cause:Z})}}class g{rpcUrl;requestId=0;websocket=null;websocketConnected=!1;pendingResponses={};subscriptionListeners={};activeSubscriptions=[];reconnectAttempt=0;initialBackoff=2000;maxBackoff=120000;constructor(J){this.rpcUrl=J}async call(J,Z){this.requestId++;let $={jsonrpc:"2.0",id:this.requestId,method:J,params:Z};try{let Y=await fetch(this.rpcUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(!Y.ok)throw M.connectionFailed(this.rpcUrl,Error(`HTTP ${Y.status}: ${Y.statusText}`));let W=await Y.json();if(W.error)throw M.fromJsonRpcError(W.error);if(W.result===void 0)throw M.invalidResponse(J,W);return W.result}catch(Y){if(Y instanceof M)throw Y;throw M.connectionFailed(this.rpcUrl,Y)}}setRpcUrl(J){this.rpcUrl=J}getRpcUrl(){return this.rpcUrl}connect(){return new Promise((J,Z)=>{let $=this.rpcUrl.replace("http","ws");if($.endsWith("/"))$+="ws/subscribe";else $+="/ws/subscribe";this.websocket=new WebSocket($),this.websocket.onopen=()=>{console.log("WebSocket connected"),this.websocketConnected=!0,this.reconnectAttempt=0,J()},this.websocket.onmessage=(Y)=>{let W=JSON.parse(Y.data),{id:G,method:V,params:q}=W;if(G!==void 0&&this.pendingResponses[G])this.pendingResponses[G].resolve(W),delete this.pendingResponses[G];if(V==="circles_subscription"&&q?.result)Object.values(this.subscriptionListeners).forEach((F)=>{F.forEach((O)=>O(q.result))})},this.websocket.onclose=()=>{console.warn("WebSocket closed");let Y=this.websocketConnected;if(this.websocketConnected=!1,Y)this.scheduleReconnect()},this.websocket.onerror=(Y)=>{console.error("WebSocket error:",Y),this.websocketConnected=!1,Z(M.connectionFailed(this.rpcUrl,Y instanceof Error?Y:Error("WebSocket connection failed"))),this.scheduleReconnect()}})}scheduleReconnect(){let J=Math.min(this.initialBackoff*Math.pow(2,this.reconnectAttempt),this.maxBackoff),Z=J*(Math.random()*0.5),$=J+Z;console.log(`Reconnecting in ${Math.round($)}ms (attempt #${this.reconnectAttempt+1})`),this.reconnectAttempt++,setTimeout(()=>{this.reconnect()},$)}async reconnect(){if(this.websocketConnected)return;try{await this.connect(),console.log("Reconnection successful"),await this.resubscribeActive()}catch(J){console.error("Reconnection attempt failed:",J),this.scheduleReconnect()}}async resubscribeActive(){if(this.activeSubscriptions.length===0)return;let J=[...this.activeSubscriptions];this.activeSubscriptions=[];for(let Z of J)try{let $=Z.address?{address:Z.address}:{},W=(await this.sendMessage("circles_subscribe",$)).result,G=this.subscriptionListeners[Z.id];if(G)this.subscriptionListeners[W]=G,delete this.subscriptionListeners[Z.id];this.activeSubscriptions.push({id:W,address:Z.address})}catch($){console.error("Failed to re-issue circles_subscribe after reconnect:",$),this.activeSubscriptions.push(Z)}}sendMessage(J,Z,$=5000){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)return Promise.reject(M.connectionFailed(this.rpcUrl));let Y=this.requestId++,W={jsonrpc:"2.0",method:J,params:Z,id:Y};return new Promise((G,V)=>{this.pendingResponses[Y]={resolve:G,reject:V},this.websocket.send(JSON.stringify(W)),setTimeout(()=>{if(this.pendingResponses[Y])this.pendingResponses[Y].reject(M.timeout(J,$)),delete this.pendingResponses[Y]},$)})}async subscribe(J){let Z=J?.toLowerCase();if(!this.websocketConnected)await this.connect();let $=D.create(),Y=Z?{address:Z}:{},G=(await this.sendMessage("circles_subscribe",Y)).result;if(!this.subscriptionListeners[G])this.subscriptionListeners[G]=[];return this.subscriptionListeners[G].push((V)=>{k(V).forEach((q)=>$.emit(q))}),this.activeSubscriptions.push({id:G,address:Z}),$.property}}var x=BigInt(4294967295),i=BigInt(32);function PJ(J,Z=!1){if(Z)return{h:Number(J&x),l:Number(J>>i&x)};return{h:Number(J>>i&x)|0,l:Number(J&x)|0}}function n(J,Z=!1){let $=J.length,Y=new Uint32Array($),W=new Uint32Array($);for(let G=0;G<$;G++){let{h:V,l:q}=PJ(J[G],Z);[Y[G],W[G]]=[V,q]}return[Y,W]}var o=(J,Z,$)=>J<<$|Z>>>32-$,t=(J,Z,$)=>Z<<$|J>>>32-$,a=(J,Z,$)=>Z<<$-32|J>>>64-$,r=(J,Z,$)=>J<<$-32|Z>>>64-$;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function LJ(J){return J instanceof Uint8Array||ArrayBuffer.isView(J)&&J.constructor.name==="Uint8Array"}function y(J,Z=""){if(!Number.isSafeInteger(J)||J<0){let $=Z&&`"${Z}" `;throw Error(`${$}expected integer >= 0, got ${J}`)}}function A(J,Z,$=""){let Y=LJ(J),W=J?.length,G=Z!==void 0;if(!Y||G&&W!==Z){let V=$&&`"${$}" `,q=G?` of length ${Z}`:"",F=Y?`length=${W}`:`type=${typeof J}`;throw Error(V+"expected Uint8Array"+q+", got "+F)}return J}function h(J,Z=!0){if(J.destroyed)throw Error("Hash instance has been destroyed");if(Z&&J.finished)throw Error("Hash#digest() has already been called")}function s(J,Z){A(J,void 0,"digestInto() output");let $=Z.outputLen;if(J.length<$)throw Error('"digestInto() output" expected to be of length >='+$)}function e(J){return new Uint32Array(J.buffer,J.byteOffset,Math.floor(J.byteLength/4))}function p(...J){for(let Z=0;Z<J.length;Z++)J[Z].fill(0)}var _J=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function RJ(J){return J<<24&4278190080|J<<8&16711680|J>>>8&65280|J>>>24&255}function TJ(J){for(let Z=0;Z<J.length;Z++)J[Z]=RJ(J[Z]);return J}var m=_J?(J)=>J:TJ;function JJ(J,Z={}){let $=(W,G)=>J(G).update(W).digest(),Y=J(void 0);return $.outputLen=Y.outputLen,$.blockLen=Y.blockLen,$.create=(W)=>J(W),Object.assign($,Z),Object.freeze($)}var CJ=BigInt(0),j=BigInt(1),zJ=BigInt(2),EJ=BigInt(7),SJ=BigInt(256),wJ=BigInt(113),YJ=[],WJ=[],GJ=[];for(let J=0,Z=j,$=1,Y=0;J<24;J++){[$,Y]=[Y,(2*$+3*Y)%5],YJ.push(2*(5*Y+$)),WJ.push((J+1)*(J+2)/2%64);let W=CJ;for(let G=0;G<7;G++)if(Z=(Z<<j^(Z>>EJ)*wJ)%SJ,Z&zJ)W^=j<<(j<<BigInt(G))-j;GJ.push(W)}var QJ=n(GJ,!0),HJ=QJ[0],BJ=QJ[1],ZJ=(J,Z,$)=>$>32?a(J,Z,$):o(J,Z,$),$J=(J,Z,$)=>$>32?r(J,Z,$):t(J,Z,$);function kJ(J,Z=24){let $=new Uint32Array(10);for(let Y=24-Z;Y<24;Y++){for(let V=0;V<10;V++)$[V]=J[V]^J[V+10]^J[V+20]^J[V+30]^J[V+40];for(let V=0;V<10;V+=2){let q=(V+8)%10,F=(V+2)%10,O=$[F],U=$[F+1],OJ=ZJ(O,U,1)^$[q],DJ=$J(O,U,1)^$[q+1];for(let B=0;B<50;B+=10)J[V+B]^=OJ,J[V+B+1]^=DJ}let W=J[2],G=J[3];for(let V=0;V<24;V++){let q=WJ[V],F=ZJ(W,G,q),O=$J(W,G,q),U=YJ[V];W=J[U],G=J[U+1],J[U]=F,J[U+1]=O}for(let V=0;V<50;V+=10){for(let q=0;q<10;q++)$[q]=J[V+q];for(let q=0;q<10;q++)J[V+q]^=~$[(q+2)%10]&$[(q+4)%10]}J[0]^=HJ[Y],J[1]^=BJ[Y]}p($)}class u{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(J,Z,$,Y=!1,W=24){if(this.blockLen=J,this.suffix=Z,this.outputLen=$,this.enableXOF=Y,this.rounds=W,y($,"outputLen"),!(0<J&&J<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=e(this.state)}clone(){return this._cloneInto()}keccak(){m(this.state32),kJ(this.state32,this.rounds),m(this.state32),this.posOut=0,this.pos=0}update(J){h(this),A(J);let{blockLen:Z,state:$}=this,Y=J.length;for(let W=0;W<Y;){let G=Math.min(Z-this.pos,Y-W);for(let V=0;V<G;V++)$[this.pos++]^=J[W++];if(this.pos===Z)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:J,suffix:Z,pos:$,blockLen:Y}=this;if(J[$]^=Z,(Z&128)!==0&&$===Y-1)this.keccak();J[Y-1]^=128,this.keccak()}writeInto(J){h(this,!1),A(J),this.finish();let Z=this.state,{blockLen:$}=this;for(let Y=0,W=J.length;Y<W;){if(this.posOut>=$)this.keccak();let G=Math.min($-this.posOut,W-Y);J.set(Z.subarray(this.posOut,this.posOut+G),Y),this.posOut+=G,Y+=G}return J}xofInto(J){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(J)}xof(J){return y(J),this.xofInto(new Uint8Array(J))}digestInto(J){if(s(J,this),this.finished)throw Error("digest() was already called");return this.writeInto(J),this.destroy(),J}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,p(this.state)}_cloneInto(J){let{blockLen:Z,suffix:$,outputLen:Y,rounds:W,enableXOF:G}=this;return J||=new u(Z,$,Y,G,W),J.state32.set(this.state32),J.pos=this.pos,J.posOut=this.posOut,J.finished=this.finished,J.rounds=W,J.suffix=$,J.outputLen=Y,J.enableXOF=G,J.destroyed=this.destroyed,J}}var gJ=(J,Z,$,Y={})=>JJ(()=>new u(Z,J,$),Y);var VJ=gJ(1,136,32);var KJ=[];for(let J=0;J<256;J++)KJ[J]=J.toString(16).padStart(2,"0");function qJ(J){let Z="0x";for(let $=0;$<J.length;$++)Z+=KJ[J[$]];return Z}function MJ(J){let Z=J.toLowerCase().replace("0x",""),$=qJ(VJ(new TextEncoder().encode(Z))).slice(2),Y="0x";for(let W=0;W<Z.length;W++)Y+=parseInt($[W],16)>=8?Z[W].toUpperCase():Z[W];return Y}function Q(J){return J.toLowerCase()}function xJ(J){return J.map((Z)=>Q(Z))}function AJ(J){return MJ(J)}function bJ(J){if(typeof J!=="string")return!1;let Z=J.replace("0x","");return Z.length===40&&/^[0-9a-fA-F]{40}$/.test(Z)}function K(J){if(J===null||J===void 0)return J;if(bJ(J))return AJ(J);if(Array.isArray(J))return J.map((Z)=>K(Z));if(typeof J==="object"&&J!==null){let Z={};for(let $ in J)if(Object.prototype.hasOwnProperty.call(J,$))Z[$]=K(J[$]);return Z}return J}function FJ(J){return{Source:Q(J.from),Sink:Q(J.to),TargetFlow:J.targetFlow.toString(),WithWrap:J.useWrappedBalances,FromTokens:J.fromTokens?.map(Q),ToTokens:J.toTokens?.map(Q),ExcludedFromTokens:J.excludeFromTokens?.map(Q),ExcludedToTokens:J.excludeToTokens?.map(Q),SimulatedBalances:J.simulatedBalances?.map((Z)=>({Holder:Q(Z.holder),Token:Q(Z.token),Amount:Z.amount.toString(),IsWrapped:Z.isWrapped,IsStatic:Z.isStatic})),SimulatedTrusts:J.simulatedTrusts?.map((Z)=>({Truster:Q(Z.truster),Trustee:Q(Z.trustee)})),MaxTransfers:J.maxTransfers}}function X(J){let Z={};for(let $ in J){let Y=J[$];if(Y===null||Y===void 0)Z[$]=Y;else if(typeof Y==="string"&&/^\d+$/.test(Y))Z[$]=BigInt(Y);else if(typeof Y==="object"&&!Array.isArray(Y))Z[$]=X(Y);else if(Array.isArray(Y))Z[$]=Y.map((W)=>typeof W==="object"&&W!==null?X(W):W);else Z[$]=Y}return Z}var KZ=BigInt(96)*BigInt(1000000000000000000),XJ=BigInt("9999999999999999999999999999999999999");class P{client;constructor(J){this.client=J}async findPath(J){let Z=FJ(J),$=await this.client.call("circlesV2_findPath",[Z]),Y=X($);return K(Y)}async findMaxFlow(J){let Z=await this.findPath({...J,targetFlow:XJ});return BigInt(Z.maxFlow)}}class L{client;constructor(J){this.client=J}async query(J){let Z=await this.client.call("circles_query",[J]),{columns:$,rows:Y}=Z,W=Y.map((G)=>{let V={};return $.forEach((q,F)=>{V[q]=G[F]}),V});return K(W)}async tables(){return this.client.call("circles_tables",[])}async events(J=null,Z=null,$=null,Y=null,W=null,G=!1,V=100,q=null){let F=await this.client.call("circles_events_paginated",[J,Z,$,Y,W,G,V,q]);return{events:K(F.events),hasMore:F.hasMore,nextCursor:F.nextCursor}}}var vJ=[{name:"blockNumber",sortOrder:"DESC"},{name:"transactionIndex",sortOrder:"DESC"},{name:"logIndex",sortOrder:"DESC"}];class N{params;client;rowTransformer;cursorColumns;orderColumns;get currentPage(){return this._currentPage}_currentPage;constructor(J,Z,$){this.client=J,this.params=Z,this.rowTransformer=$||Z.rowTransformer,this.orderColumns=Z.orderColumns,this.cursorColumns=Z.cursorColumns||this.buildEventCursorColumns()}buildEventCursorColumns(){let J=vJ.map((Z)=>({...Z,sortOrder:this.params.sortOrder}));if(this.params.table==="TransferBatch")J.push({name:"batchIndex",sortOrder:this.params.sortOrder});return J}buildOrderBy(){if(this.orderColumns&&this.orderColumns.length>0)return this.orderColumns;return this.cursorColumns.map((J)=>({Column:J.name,SortOrder:J.sortOrder}))}rowsToObjects(J){let{columns:Z,rows:$}=J;return $.map((Y)=>{let W={};return Z.forEach((G,V)=>{W[G]=Y[V]}),this.rowTransformer?this.rowTransformer(W):W})}async queryNextPage(){let J={Namespace:this.params.namespace,Table:this.params.table,Columns:this.params.columns,Filter:this.params.filter||[],Order:this.buildOrderBy(),Limit:this.params.limit},Z=this._currentPage?.nextCursor?[J,this._currentPage.nextCursor]:[J],$=await this.client.call("circles_paginated_query",Z),Y=this.rowsToObjects($);return this._currentPage={limit:this.params.limit,size:Y.length,sortOrder:this.params.sortOrder,hasMore:$.hasMore,nextCursor:$.nextCursor??void 0,results:Y},Y.length>0}reset(){this._currentPage=void 0}}class _{client;constructor(J){this.client=J}transformQueryResponse(J){let{columns:Z,rows:$}=J;return $.map((Y)=>{let W={};return Z.forEach((G,V)=>{W[G]=Y[V]}),W})}async getCommonTrust(J,Z){let $=await this.client.call("circles_getCommonTrust",[Q(J),Q(Z)]);return K($)}getTrustRelations(J,Z=100,$="DESC"){let Y=Q(J),W=[{Type:"Conjunction",ConjunctionType:"And",Predicates:[{Type:"FilterPredicate",FilterType:"Equals",Column:"version",Value:2},{Type:"Conjunction",ConjunctionType:"Or",Predicates:[{Type:"FilterPredicate",FilterType:"Equals",Column:"trustee",Value:Y},{Type:"FilterPredicate",FilterType:"Equals",Column:"truster",Value:Y}]}]}];return new N(this.client,{namespace:"V_Crc",table:"TrustRelations",sortOrder:$,columns:["blockNumber","timestamp","transactionIndex","logIndex","transactionHash","version","trustee","truster","expiryTime"],filter:W,limit:Z},(G)=>K(G))}async getAggregatedTrustRelations(J){let Z=Q(J),$=await this.client.call("circles_getAggregatedTrustRelations",[Z]);return K($)}async getTrustedBy(J){let Z=Q(J),Y=(await this.getAggregatedTrustRelations(Z)).filter((W)=>W.relation==="trustedBy");return K(Y)}async getTrusts(J){let Z=Q(J),Y=(await this.getAggregatedTrustRelations(Z)).filter((W)=>W.relation==="trusts");return K(Y)}async getMutualTrusts(J){let Z=Q(J),Y=(await this.getAggregatedTrustRelations(Z)).filter((W)=>W.relation==="mutuallyTrusts");return K(Y)}async getTrustNetworkSummary(J,Z=2){return this.client.call("circles_getTrustNetworkSummary",[Q(J),Z])}async getAggregatedTrustRelationsEnriched(J){return this.client.call("circles_getAggregatedTrustRelationsEnriched",[Q(J)])}async getValidInviters(J,Z){let $=[Q(J)];if(Z)$.push(Z);return this.client.call("circles_getValidInviters",$)}}class c{static ONE_64=1n<<64n;static GAMMA_64=18443079296116538654n;static BETA_64=18450409579521241655n;static SECONDS_PER_DAY=86400n;static INFLATION_DAY_ZERO_UNIX=1602720000n;static ATTO_FACTOR=1000000000000000000n;static FACTOR_1E12=1000000000000n;static V1_ACCURACY=100000000n;static V1_INFLATION_PCT_NUM=107n;static V1_INFLATION_PCT_DEN=100n;static PERIOD_SEC=31556952n;static mul64(J,Z){return J*Z>>64n}static mulU(J,Z){return J*Z>>64n}static pow64(J,Z){let $=J,Y=Z,W=this.ONE_64;while(Y>0n){if((Y&1n)===1n)W=this.mul64(W,$);$=this.mul64($,$),Y>>=1n}return W}static ONE_36=1000000000000000000000000000000000000000n;static GAMMA_36=999801332008598957430613406568191166n;static BETA_36=1000198707468214629156271489013303962n;static mul36(J,Z){return J*Z/this.ONE_36}static pow36(J,Z){let $=this.ONE_36,Y=J,W=Z;while(W>0n){if((W&1n)===1n)$=this.mul36($,Y);Y=this.mul36(Y,Y),W>>=1n}return $}static attoCirclesToCircles(J){if(J===0n)return 0;let Z=J/this.ATTO_FACTOR,$=J%this.ATTO_FACTOR,Y=BigInt(Number.MAX_SAFE_INTEGER);if(Z>Y||Z<-Y)throw RangeError("Atto value’s integer component exceeds JS double precision.");return Number(Z)+Number($)/Number(this.ATTO_FACTOR)}static circlesToAttoCircles(J){return BigInt(Math.trunc(J*Number(this.ATTO_FACTOR)))}static inflationaryToDemurrage(J,Z){return this.mulU(this.pow64(this.GAMMA_64,Z),J)}static demurrageToInflationary(J,Z){return this.mulU(this.pow64(this.BETA_64,Z),J)}static dayFromTimestamp(J){return(J-this.INFLATION_DAY_ZERO_UNIX)/this.SECONDS_PER_DAY}static attoCirclesToAttoStaticCircles(J,Z=BigInt(Math.floor(Date.now()/1000))){return this.demurrageToInflationary(J,this.dayFromTimestamp(Z))}static attoStaticCirclesToAttoCircles(J,Z=BigInt(Math.floor(Date.now()/1000))){return this.inflationaryToDemurrage(J,this.dayFromTimestamp(Z))}static inflationaryToDemurrageExact(J,Z){let $=this.pow36(this.GAMMA_36,Z);return J*$/this.ONE_36}static demurrageToInflationaryExact(J,Z){let $=this.pow36(this.BETA_36,Z);return J*$/this.ONE_36}static attoCirclesToAttoStaticCirclesExact(J,Z=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Z);return this.demurrageToInflationaryExact(J,$)}static attoStaticCirclesToAttoCirclesExact(J,Z=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Z);return this.inflationaryToDemurrageExact(J,$)}static truncateToInt64(J){let Z=J/this.FACTOR_1E12,$=9223372036854775807n;return Z>$?$:Z}static blowUpToBigInt(J){return J*this.FACTOR_1E12}static truncateToSixDecimals(J){return this.blowUpToBigInt(this.truncateToInt64(J))}static v1InflateFactor(J){if(J===0n)return this.V1_ACCURACY;return this.V1_ACCURACY*this.V1_INFLATION_PCT_NUM**J/this.V1_INFLATION_PCT_DEN**J}static attoCrcToAttoCircles(J,Z){let $=Z-this.INFLATION_DAY_ZERO_UNIX,Y=$/this.PERIOD_SEC,W=$%this.PERIOD_SEC,G=this.v1InflateFactor(Y),V=this.v1InflateFactor(Y+1n);return this.v1ToDemurrage(J,G,V,W,this.PERIOD_SEC)}static attoCirclesToAttoCrc(J,Z){let $=Z-this.INFLATION_DAY_ZERO_UNIX,Y=$/this.PERIOD_SEC,W=$%this.PERIOD_SEC,G=this.v1InflateFactor(Y),V=this.v1InflateFactor(Y+1n),q=G*(this.PERIOD_SEC-W)+V*W;return J*3n*this.V1_ACCURACY*this.PERIOD_SEC/q}static v1ToDemurrage(J,Z,$,Y,W){let G=Z*(W-Y)+$*Y;return J*3n*this.V1_ACCURACY*W/G}}class R{client;constructor(J){this.client=J}async getTotalBalance(J,Z=!0){let $=await this.client.call("circlesV2_getTotalBalance",[Q(J),Z]);return c.circlesToAttoCircles($)}async getTokenBalances(J){let $=(await this.client.call("circles_getTokenBalances",[Q(J)])).map((Y)=>X(Y));return K($)}}class T{client;constructor(J){this.client=J}async getAvatarInfo(J){let Z=await this.getAvatarInfoBatch([J]);return Z.length>0?Z[0]:void 0}async getAvatarInfoBatch(J){if(J.length===0)return[];let Z=J.map((Y)=>Q(Y)),$=await this.client.call("circles_getAvatarInfoBatch",[Z]);return K($)}async getNetworkSnapshot(){let J=await this.client.call("circles_getNetworkSnapshot",[]);return K(J)}}class C{client;constructor(J){this.client=J}async getProfileByCid(J){return this.client.call("circles_getProfileByCid",[J])}async getProfileByCidBatch(J){return this.client.call("circles_getProfileByCidBatch",[J])}async getProfileByAddress(J){return this.client.call("circles_getProfileByAddress",[Q(J)])}async getProfileByAddressBatch(J){return this.client.call("circles_getProfileByAddressBatch",[J.map((Z)=>Z===null?null:Q(Z))])}async searchProfiles(J,Z=10,$=0,Y){return this.client.call("circles_searchProfiles",[J.toLowerCase(),Z,$,Y])}async searchByAddressOrName(J,Z=10,$,Y){return this.client.call("circles_searchProfileByAddressOrName",Y?[J,Z,$??null,Y]:[J,Z,$??null])}async getProfileView(J){return this.client.call("circles_getProfileView",[Q(J)])}}class z{client;constructor(J){this.client=J}async getTokenInfo(J){let Z=await this.getTokenInfoBatch([J]);return Z.length>0?Z[0]:void 0}async getTokenInfoBatch(J){if(J.length===0)return[];let Z=J.map((W)=>Q(W)),Y=(await this.client.call("circles_getTokenInfoBatch",[Z])).map((W)=>X(W));return K(Y)}async getTokenHolders(J,Z=100,$){let Y=await this.client.call("circles_getTokenHolders",[Q(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}}class E{client;constructor(J){this.client=J}async getInvitationOrigin(J){let Z=Q(J),$=await this.client.call("circles_getInvitationOrigin",[Z]);return $?K($):null}async getInvitedBy(J){let Z=await this.getInvitationOrigin(J);if(Z?.inviter)return K(Z.inviter);return}async getTrustInvitations(J,Z){let $=Q(J),Y=await this.client.call("circles_getTrustInvitations",Z?[$,Z]:[$]);return K(Y)}async getInvitations(J,Z){let Y=(await this.getValidInviters(J,Z)).results.map((W)=>W.avatarInfo).filter((W)=>W!==void 0&&W!==null);return K(Y)}async getValidInviters(J,Z){let $=Q(J),Y=await this.client.call("circles_getValidInviters",Z?[$,Z]:[$]);return K(Y)}async getInvitationsFrom(J,Z=!1){let $=Q(J),Y=await this.client.call("circles_getInvitationsFrom",[$,Z]);return K(Y)}async getEscrowInvitations(J){let Z=Q(J),$=await this.client.call("circles_getEscrowInvitations",[Z]);return K($)}async getAtScaleInvitations(J){let Z=Q(J),$=await this.client.call("circles_getAtScaleInvitations",[Z]);return K($)}async getAllInvitations(J,Z){let $=Q(J),Y=await this.client.call("circles_getAllInvitations",Z?[$,Z]:[$]);return K(Y)}}class S{client;constructor(J){this.client=J}async getTransactionHistory(J,Z=50,$){let Y=await this.client.call("circles_getTransactionHistory",[Q(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}async getTransactionHistoryEnriched(J,Z=0,$=null,Y=20,W){let G=await this.client.call("circles_getTransactionHistoryEnriched",[Q(J),Z,$,Y,W??null]);return{hasMore:G.hasMore,nextCursor:G.nextCursor,results:K(G.results)}}async getTransferData(J,Z,$,Y,W,G=50,V){let q=await this.client.call("circles_getTransferData",[Q(J),Z??null,$?Q($):null,Y??null,W??null,G,V??null]);return{hasMore:q.hasMore,nextCursor:q.nextCursor,results:K(q.results)}}}class w{client;constructor(J){this.client=J}async findGroups(J=50,Z,$){let Y=Z?{nameStartsWith:Z.nameStartsWith,symbolStartsWith:Z.symbolStartsWith,ownerIn:Z.ownerIn?.map((V)=>Q(V))}:void 0,W=await this.client.call("circles_findGroups",[J,Y??null,$??null]),G=K(W.results).map((V)=>{let q=V;if(!q.owner&&q.mint)return{...q,owner:q.mint};return q});return{hasMore:W.hasMore,nextCursor:W.nextCursor,results:G}}async getGroupMemberships(J,Z=50,$){let Y=await this.client.call("circles_getGroupMemberships",[Q(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}async getGroupMembers(J,Z=100,$){let Y=await this.client.call("circles_getGroupMembers",[Q(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}getGroups(J=50,Z,$="DESC"){let Y=[];if(Z){if(Z.nameStartsWith)Y.push({Type:"FilterPredicate",FilterType:"Like",Column:"name",Value:Z.nameStartsWith+"%"});if(Z.symbolStartsWith)Y.push({Type:"FilterPredicate",FilterType:"Like",Column:"symbol",Value:Z.symbolStartsWith+"%"});if(Z.groupAddressIn&&Z.groupAddressIn.length>0){let G=Z.groupAddressIn.map((V)=>({Type:"FilterPredicate",FilterType:"Equals",Column:"group",Value:Q(V)}));if(G.length===1)Y.push(G[0]);else Y.push({Type:"Conjunction",ConjunctionType:"Or",Predicates:G})}if(Z.groupTypeIn&&Z.groupTypeIn.length>0){let G=Z.groupTypeIn.map((V)=>({Type:"FilterPredicate",FilterType:"Equals",Column:"type",Value:V}));if(G.length===1)Y.push(G[0]);else Y.push({Type:"Conjunction",ConjunctionType:"Or",Predicates:G})}if(Z.ownerIn&&Z.ownerIn.length>0){let G=Z.ownerIn.map((V)=>({Type:"FilterPredicate",FilterType:"Equals",Column:"owner",Value:Q(V)}));if(G.length===1)Y.push(G[0]);else Y.push({Type:"Conjunction",ConjunctionType:"Or",Predicates:G})}if(Z.mintHandlerEquals)Y.push({Type:"FilterPredicate",FilterType:"Equals",Column:"mintHandler",Value:Q(Z.mintHandlerEquals)});if(Z.treasuryEquals)Y.push({Type:"FilterPredicate",FilterType:"Equals",Column:"treasury",Value:Q(Z.treasuryEquals)})}let W=Y.length>1?[{Type:"Conjunction",ConjunctionType:"And",Predicates:Y}]:Y;return new N(this.client,{namespace:"V_CrcV2",table:"Groups",sortOrder:$,columns:["blockNumber","timestamp","transactionIndex","logIndex","transactionHash","group","type","owner","mintPolicy","mintHandler","treasury","service","feeCollection","memberCount","name","symbol","cidV0Digest","erc20WrapperDemurraged","erc20WrapperStatic"],filter:W,limit:J},(G)=>K(G))}getGroupHolders(J,Z=100){let $=Q(J);return new N(this.client,{namespace:"V_Crc",table:"TokenBalances",sortOrder:"DESC",columns:["blockNumber","timestamp","transactionIndex","logIndex","transactionHash","token","account","balance","lastChangedAt"],filter:[{Type:"FilterPredicate",FilterType:"Equals",Column:"token",Value:$}],limit:Z},(Y)=>K(Y))}}class H{client;constructor(J){this.client=J}async getAffiliateGroupWishlist(J){let Z=await this.client.call("circles_getAffiliateGroupWishlist",[Q(J)]);return UJ(Z)}async getAffiliateGroups(J){let Z=await this.client.call("circles_getAffiliateGroups",[Q(J)]);return UJ(Z)}async getAffiliateGroupFeesPercentage(J){let Z=await this.client.call("circles_getAffiliateGroupFeesPercentage",[Q(J)]);return Number(Z?.totalFeePercentage??0)}async getAffiliateGroupMembersWishlist(J,Z=100,$){let Y=await this.client.call("circles_getAffiliateGroupMembersWishlist",[Q(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}async getAffiliateGroupMembers(J,Z=100,$){let Y=await this.client.call("circles_getAffiliateGroupMembers",[Q(J),Z,$??null]);return{hasMore:Y.hasMore,nextCursor:Y.nextCursor,results:K(Y.results)}}}function UJ(J){return{totalFeePercentage:Number(J?.totalFeePercentage??0),groups:K(J?.groups??[])}}class b{client;constructor(J){this.client=J}async getProfileView(J){let Z=Q(J);return this.client.call("circles_getProfileView",[Z])}async getTrustNetworkSummary(J,Z=2){let $=Q(J);return this.client.call("circles_getTrustNetworkSummary",[$,Z])}async getAggregatedTrustRelations(J){let Z=Q(J);return this.client.call("circles_getAggregatedTrustRelations",[Z])}async getValidInviters(J,Z){let $=Q(J),Y=await this.client.call("circles_getValidInviters",Z?[$,Z]:[$]);return K(Y)}async getTransactionHistoryEnriched(J,Z=0,$=null,Y=50,W){let G=Q(J),V=await this.client.call("circles_getTransactionHistoryEnriched",[G,Z,$,Y,W??null]);return{hasMore:V.hasMore,nextCursor:V.nextCursor,results:K(V.results)}}async searchProfileByAddressOrName(J,Z=20,$,Y){return this.client.call("circles_searchProfileByAddressOrName",Y?[J,Z,$??null,Y]:[J,Z,$??null])}}class NJ{client;_pathfinder;_query;_trust;_balance;_avatar;_profile;_token;_invitation;_transaction;_group;_affiliate;_sdk;constructor(J="https://rpc.aboutcircles.com/"){this.client=new g(J)}get pathfinder(){if(!this._pathfinder)this._pathfinder=new P(this.client);return this._pathfinder}get query(){if(!this._query)this._query=new L(this.client);return this._query}get trust(){if(!this._trust)this._trust=new _(this.client);return this._trust}get balance(){if(!this._balance)this._balance=new R(this.client);return this._balance}get avatar(){if(!this._avatar)this._avatar=new T(this.client);return this._avatar}get profile(){if(!this._profile)this._profile=new C(this.client);return this._profile}get token(){if(!this._token)this._token=new z(this.client);return this._token}get invitation(){if(!this._invitation)this._invitation=new E(this.client);return this._invitation}get transaction(){if(!this._transaction)this._transaction=new S(this.client);return this._transaction}get group(){if(!this._group)this._group=new w(this.client);return this._group}get affiliate(){if(!this._affiliate)this._affiliate=new H(this.client);return this._affiliate}get sdk(){if(!this._sdk)this._sdk=new b(this.client);return this._sdk}setRpcUrl(J){this.client.setRpcUrl(J)}getRpcUrl(){return this.client.getRpcUrl()}}export{X as parseStringsToBigInt,k as parseRpcSubscriptionMessage,v as parseRpcEvent,xJ as normalizeAddresses,Q as normalizeAddress,l as isCirclesEvent,_ as TrustMethods,S as TransactionMethods,z as TokenMethods,M as RpcError,g as RpcClient,L as QueryMethods,C as ProfileMethods,P as PathfinderMethods,N as PagedQuery,D as Observable,E as InvitationMethods,w as GroupMethods,NJ as CirclesRpc,R as BalanceMethods,T as AvatarMethods,H as AffiliateMethods};
@@ -0,0 +1,72 @@
1
+ import type { RpcClient } from '../client.js';
2
+ import type { Address, AffiliateGroupListResponse, AffiliateGroupMemberRow, PagedResponse } from '@aboutcircles/sdk-types';
3
+ /**
4
+ * Affiliate-group ("communities", GA 2.0) RPC methods.
5
+ *
6
+ * Backed by the MultiAffiliateGroupRegistry: an avatar signals on-chain *intent* to join
7
+ * a group (the "wishlist"); a group becomes a confirmed membership once it also trusts the
8
+ * avatar (the bilateral handshake) — so the **trusted** subset always lags, and is a subset
9
+ * of, the wishlist. Each group's `membershipFee` is read off its profile; an avatar's fees
10
+ * across all communities are capped at 100% by the consumer (the registry does not enforce
11
+ * it). Use {@link getAffiliateGroupFeesPercentage} for the pre-join cap check.
12
+ *
13
+ * Write side (signalling intent) is `MultiAffiliateGroupRegistryContract` in `@aboutcircles/sdk-core`.
14
+ *
15
+ * @remarks These methods are served by the indexer RPC and roll out staging-first; an RPC
16
+ * endpoint that predates the feature rejects them with JSON-RPC `-32601` (method not found),
17
+ * so callers should degrade gracefully (treat `-32601` as "unavailable on this endpoint").
18
+ * They always read chain head — `X-Max-Block-Number` block-pinning is a no-op here.
19
+ */
20
+ export declare class AffiliateMethods {
21
+ private client;
22
+ constructor(client: RpcClient);
23
+ /**
24
+ * The groups an avatar has signalled intent to join (the wishlist), each with its
25
+ * membership fee, plus the summed total committed fee percentage.
26
+ *
27
+ * @param avatar - The avatar whose wishlist to read
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const { totalFeePercentage, groups } = await rpc.affiliate.getAffiliateGroupWishlist(
32
+ * '0x112b5cee910a077e4bd28ec158e35653b3ac2350'
33
+ * );
34
+ * ```
35
+ */
36
+ getAffiliateGroupWishlist(avatar: Address): Promise<AffiliateGroupListResponse>;
37
+ /**
38
+ * The confirmed-membership subset of the wishlist: groups that currently trust the
39
+ * avatar on-chain. `totalFeePercentage` is summed over this confirmed subset, so it
40
+ * reflects the TMS trust delay (a wished group only appears here once it trusts the avatar).
41
+ *
42
+ * @param avatar - The avatar whose confirmed communities to read
43
+ */
44
+ getAffiliateGroups(avatar: Address): Promise<AffiliateGroupListResponse>;
45
+ /**
46
+ * The avatar's total committed fee percentage across its **wishlist** (intent set) —
47
+ * the number to check against the 100% cap before signalling a new join.
48
+ *
49
+ * @param avatar - The avatar whose committed fee total to read
50
+ * @returns The summed fee percentage (a `null` per-group fee counts as 0)
51
+ */
52
+ getAffiliateGroupFeesPercentage(avatar: Address): Promise<number>;
53
+ /**
54
+ * The avatars that have signalled intent to join the group (the group's members
55
+ * wishlist). This is the set the TMS reconciles against. Paginated.
56
+ *
57
+ * @param groupAddress - The group whose intended members to list
58
+ * @param limit - Max members per page (1–1000, clamped server-side; default 100)
59
+ * @param cursor - Opaque page token from a prior `nextCursor` (omit for the first page)
60
+ */
61
+ getAffiliateGroupMembersWishlist(groupAddress: Address, limit?: number, cursor?: string | null): Promise<PagedResponse<AffiliateGroupMemberRow>>;
62
+ /**
63
+ * The confirmed-membership subset of a group's wishlist: avatars the group actually
64
+ * trusts on-chain. Reflects the TMS trust delay. Paginated.
65
+ *
66
+ * @param groupAddress - The group whose confirmed members to list
67
+ * @param limit - Max members per page (1–1000, clamped server-side; default 100)
68
+ * @param cursor - Opaque page token from a prior `nextCursor` (omit for the first page)
69
+ */
70
+ getAffiliateGroupMembers(groupAddress: Address, limit?: number, cursor?: string | null): Promise<PagedResponse<AffiliateGroupMemberRow>>;
71
+ }
72
+ //# sourceMappingURL=affiliate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affiliate.d.ts","sourceRoot":"","sources":["../../src/methods/affiliate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,OAAO,EAEP,0BAA0B,EAC1B,uBAAuB,EACvB,aAAa,EACd,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAErC;;;;;;;;;;;;OAYG;IACG,yBAAyB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAQrF;;;;;;OAMG;IACG,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAQ9E;;;;;;OAMG;IACG,+BAA+B,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAQvE;;;;;;;OAOG;IACG,gCAAgC,CACpC,YAAY,EAAE,OAAO,EACrB,KAAK,GAAE,MAAY,EACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IAYlD;;;;;;;OAOG;IACG,wBAAwB,CAC5B,YAAY,EAAE,OAAO,EACrB,KAAK,GAAE,MAAY,EACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;CAWnD"}
@@ -0,0 +1,102 @@
1
+ import { normalizeAddress, checksumAddresses } from '../utils.js';
2
+ /**
3
+ * Affiliate-group ("communities", GA 2.0) RPC methods.
4
+ *
5
+ * Backed by the MultiAffiliateGroupRegistry: an avatar signals on-chain *intent* to join
6
+ * a group (the "wishlist"); a group becomes a confirmed membership once it also trusts the
7
+ * avatar (the bilateral handshake) — so the **trusted** subset always lags, and is a subset
8
+ * of, the wishlist. Each group's `membershipFee` is read off its profile; an avatar's fees
9
+ * across all communities are capped at 100% by the consumer (the registry does not enforce
10
+ * it). Use {@link getAffiliateGroupFeesPercentage} for the pre-join cap check.
11
+ *
12
+ * Write side (signalling intent) is `MultiAffiliateGroupRegistryContract` in `@aboutcircles/sdk-core`.
13
+ *
14
+ * @remarks These methods are served by the indexer RPC and roll out staging-first; an RPC
15
+ * endpoint that predates the feature rejects them with JSON-RPC `-32601` (method not found),
16
+ * so callers should degrade gracefully (treat `-32601` as "unavailable on this endpoint").
17
+ * They always read chain head — `X-Max-Block-Number` block-pinning is a no-op here.
18
+ */
19
+ export class AffiliateMethods {
20
+ client;
21
+ constructor(client) {
22
+ this.client = client;
23
+ }
24
+ /**
25
+ * The groups an avatar has signalled intent to join (the wishlist), each with its
26
+ * membership fee, plus the summed total committed fee percentage.
27
+ *
28
+ * @param avatar - The avatar whose wishlist to read
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const { totalFeePercentage, groups } = await rpc.affiliate.getAffiliateGroupWishlist(
33
+ * '0x112b5cee910a077e4bd28ec158e35653b3ac2350'
34
+ * );
35
+ * ```
36
+ */
37
+ async getAffiliateGroupWishlist(avatar) {
38
+ const response = await this.client.call('circles_getAffiliateGroupWishlist', [normalizeAddress(avatar)]);
39
+ return normalizeListResponse(response);
40
+ }
41
+ /**
42
+ * The confirmed-membership subset of the wishlist: groups that currently trust the
43
+ * avatar on-chain. `totalFeePercentage` is summed over this confirmed subset, so it
44
+ * reflects the TMS trust delay (a wished group only appears here once it trusts the avatar).
45
+ *
46
+ * @param avatar - The avatar whose confirmed communities to read
47
+ */
48
+ async getAffiliateGroups(avatar) {
49
+ const response = await this.client.call('circles_getAffiliateGroups', [normalizeAddress(avatar)]);
50
+ return normalizeListResponse(response);
51
+ }
52
+ /**
53
+ * The avatar's total committed fee percentage across its **wishlist** (intent set) —
54
+ * the number to check against the 100% cap before signalling a new join.
55
+ *
56
+ * @param avatar - The avatar whose committed fee total to read
57
+ * @returns The summed fee percentage (a `null` per-group fee counts as 0)
58
+ */
59
+ async getAffiliateGroupFeesPercentage(avatar) {
60
+ const response = await this.client.call('circles_getAffiliateGroupFeesPercentage', [normalizeAddress(avatar)]);
61
+ return Number(response?.totalFeePercentage ?? 0);
62
+ }
63
+ /**
64
+ * The avatars that have signalled intent to join the group (the group's members
65
+ * wishlist). This is the set the TMS reconciles against. Paginated.
66
+ *
67
+ * @param groupAddress - The group whose intended members to list
68
+ * @param limit - Max members per page (1–1000, clamped server-side; default 100)
69
+ * @param cursor - Opaque page token from a prior `nextCursor` (omit for the first page)
70
+ */
71
+ async getAffiliateGroupMembersWishlist(groupAddress, limit = 100, cursor) {
72
+ const response = await this.client.call('circles_getAffiliateGroupMembersWishlist', [normalizeAddress(groupAddress), limit, cursor ?? null]);
73
+ return {
74
+ hasMore: response.hasMore,
75
+ nextCursor: response.nextCursor,
76
+ results: checksumAddresses(response.results),
77
+ };
78
+ }
79
+ /**
80
+ * The confirmed-membership subset of a group's wishlist: avatars the group actually
81
+ * trusts on-chain. Reflects the TMS trust delay. Paginated.
82
+ *
83
+ * @param groupAddress - The group whose confirmed members to list
84
+ * @param limit - Max members per page (1–1000, clamped server-side; default 100)
85
+ * @param cursor - Opaque page token from a prior `nextCursor` (omit for the first page)
86
+ */
87
+ async getAffiliateGroupMembers(groupAddress, limit = 100, cursor) {
88
+ const response = await this.client.call('circles_getAffiliateGroupMembers', [normalizeAddress(groupAddress), limit, cursor ?? null]);
89
+ return {
90
+ hasMore: response.hasMore,
91
+ nextCursor: response.nextCursor,
92
+ results: checksumAddresses(response.results),
93
+ };
94
+ }
95
+ }
96
+ /** Checksum group addresses and coerce the summed fee to a number (a null total → 0). */
97
+ function normalizeListResponse(response) {
98
+ return {
99
+ totalFeePercentage: Number(response?.totalFeePercentage ?? 0),
100
+ groups: checksumAddresses(response?.groups ?? []),
101
+ };
102
+ }
@@ -8,5 +8,6 @@ export { TokenMethods } from './token.js';
8
8
  export { InvitationMethods } from './invitation.js';
9
9
  export { TransactionMethods } from './transaction.js';
10
10
  export { GroupMethods } from './group.js';
11
+ export { AffiliateMethods } from './affiliate.js';
11
12
  export { SdkMethods } from './sdk.js';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/methods/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/methods/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
@@ -8,4 +8,5 @@ export { TokenMethods } from './token.js';
8
8
  export { InvitationMethods } from './invitation.js';
9
9
  export { TransactionMethods } from './transaction.js';
10
10
  export { GroupMethods } from './group.js';
11
+ export { AffiliateMethods } from './affiliate.js';
11
12
  export { SdkMethods } from './sdk.js';
package/dist/rpc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RpcClient } from './client.js';
2
- import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, SdkMethods } from './methods/index.js';
2
+ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, AffiliateMethods, SdkMethods } from './methods/index.js';
3
3
  /**
4
4
  * Main RPC class for Circles protocol RPC interactions
5
5
  *
@@ -49,6 +49,7 @@ export declare class CirclesRpc {
49
49
  private _invitation?;
50
50
  private _transaction?;
51
51
  private _group?;
52
+ private _affiliate?;
52
53
  private _sdk?;
53
54
  /**
54
55
  * Create a new CirclesRpc instance
@@ -66,6 +67,7 @@ export declare class CirclesRpc {
66
67
  get invitation(): InvitationMethods;
67
68
  get transaction(): TransactionMethods;
68
69
  get group(): GroupMethods;
70
+ get affiliate(): AffiliateMethods;
69
71
  get sdk(): SdkMethods;
70
72
  /**
71
73
  * Update the RPC URL
package/dist/rpc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACX,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,UAAU;IACrB,SAAgB,MAAM,EAAE,SAAS,CAAC;IAElC,OAAO,CAAC,WAAW,CAAC,CAAoB;IACxC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,WAAW,CAAC,CAAoB;IACxC,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,IAAI,CAAC,CAAa;IAE1B;;;;OAIG;gBACS,MAAM,GAAE,MAAwC;IAI5D,IAAI,UAAU,IAAI,iBAAiB,CAKlC;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,OAAO,IAAI,cAAc,CAK5B;IAED,IAAI,MAAM,IAAI,aAAa,CAK1B;IAED,IAAI,OAAO,IAAI,cAAc,CAK5B;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,UAAU,IAAI,iBAAiB,CAKlC;IAED,IAAI,WAAW,IAAI,kBAAkB,CAKpC;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,GAAG,IAAI,UAAU,CAKpB;IAED;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
1
+ {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACX,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,UAAU;IACrB,SAAgB,MAAM,EAAE,SAAS,CAAC;IAElC,OAAO,CAAC,WAAW,CAAC,CAAoB;IACxC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,WAAW,CAAC,CAAoB;IACxC,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,UAAU,CAAC,CAAmB;IACtC,OAAO,CAAC,IAAI,CAAC,CAAa;IAE1B;;;;OAIG;gBACS,MAAM,GAAE,MAAwC;IAI5D,IAAI,UAAU,IAAI,iBAAiB,CAKlC;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,OAAO,IAAI,cAAc,CAK5B;IAED,IAAI,MAAM,IAAI,aAAa,CAK1B;IAED,IAAI,OAAO,IAAI,cAAc,CAK5B;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,UAAU,IAAI,iBAAiB,CAKlC;IAED,IAAI,WAAW,IAAI,kBAAkB,CAKpC;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,SAAS,IAAI,gBAAgB,CAKhC;IAED,IAAI,GAAG,IAAI,UAAU,CAKpB;IAED;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
package/dist/rpc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RpcClient } from './client.js';
2
- import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, SdkMethods, } from './methods/index.js';
2
+ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, AffiliateMethods, SdkMethods, } from './methods/index.js';
3
3
  /**
4
4
  * Main RPC class for Circles protocol RPC interactions
5
5
  *
@@ -49,6 +49,7 @@ export class CirclesRpc {
49
49
  _invitation;
50
50
  _transaction;
51
51
  _group;
52
+ _affiliate;
52
53
  _sdk;
53
54
  /**
54
55
  * Create a new CirclesRpc instance
@@ -118,6 +119,12 @@ export class CirclesRpc {
118
119
  }
119
120
  return this._group;
120
121
  }
122
+ get affiliate() {
123
+ if (!this._affiliate) {
124
+ this._affiliate = new AffiliateMethods(this.client);
125
+ }
126
+ return this._affiliate;
127
+ }
121
128
  get sdk() {
122
129
  if (!this._sdk) {
123
130
  this._sdk = new SdkMethods(this.client);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aboutcircles/sdk-rpc",
3
- "version": "0.1.57",
3
+ "version": "0.1.58-rc.0",
4
4
  "description": "Circles RPC wrapper",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,8 +25,8 @@
25
25
  "dev": "tsc --watch"
26
26
  },
27
27
  "dependencies": {
28
- "@aboutcircles/sdk-types": "*",
29
- "@aboutcircles/sdk-utils": "*"
28
+ "@aboutcircles/sdk-types": "0.1.58-rc.0",
29
+ "@aboutcircles/sdk-utils": "0.1.58-rc.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@esbuild-kit/esm-loader": "^2.6.5",