@hub3js/stellar 0.0.0-experimental-29a36fc0-20260720
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/builders.d.ts +5 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/mod.d.ts +5 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +2 -0
- package/dist/mod.js.map +7 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +43 -0
- package/readme.md +3 -0
- package/src/builders.ts +26 -0
- package/src/constants.ts +9 -0
- package/src/mod.ts +5 -0
- package/src/types.ts +14 -0
- package/src/utils.ts +13 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StellarActions } from './types.js';
|
|
2
|
+
import { ActionBuilder } from '@hub3js/core';
|
|
3
|
+
export declare const connect: () => ActionBuilder<StellarActions, "connect">;
|
|
4
|
+
export declare const balanceLines: ActionBuilder<StellarActions, "balanceLines">;
|
|
5
|
+
//# sourceMappingURL=builders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAU7C,eAAO,MAAM,OAAO,gDAIc,CAAC;AAEnC,eAAO,MAAM,YAAY,+CAOvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,eAAO,MAAM,WAAW,gCAAgC,CAAC"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var e=(t,o)=>s(t,"name",{value:o,configurable:!0});var a=(t,o)=>{for(var n in o)s(t,n,{get:o[n],enumerable:!0})};var p={};a(p,{balanceLines:()=>_,connect:()=>C});import{ActionBuilder as A}from"@hub3js/core";import{connectAndUpdateStateForSingleNetwork as f,intoConnecting as I,intoConnectionFinished as S}from"@hub3js/std/operators";import*as l from"@stellar/stellar-sdk";var r="stellar",c="mainnet",i="https://horizon.stellar.org";var C=e(()=>new A("connect").and(f).before(I).after(S),"connect"),_=new A("balanceLines").action(async function(t,o){return(await new l.Horizon.Server(i).loadAccount(o)).balances});var m={};a(m,{formatAddressToCAIP:()=>u});import{AccountId as d}from"caip";function u(t){return d.format({address:t,chainId:{namespace:r,reference:c}})}e(u,"formatAddressToCAIP");export{r as CAIP_NAMESPACE,c as CAIP_STELLAR_CHAIN_ID,p as builders,m as utils};
|
|
2
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/builders.ts", "../src/constants.ts", "../src/utils.ts"],
|
|
4
|
+
"sourcesContent": ["import type { StellarActions } from './types.js';\n\nimport { ActionBuilder } from '@hub3js/core';\nimport {\n connectAndUpdateStateForSingleNetwork,\n intoConnecting,\n intoConnectionFinished,\n} from '@hub3js/std/operators';\nimport * as StellarSdk from '@stellar/stellar-sdk';\n\nimport { HORIZON_URL } from './constants.js';\n\nexport const connect = () =>\n new ActionBuilder<StellarActions, 'connect'>('connect')\n .and(connectAndUpdateStateForSingleNetwork)\n .before(intoConnecting)\n .after(intoConnectionFinished);\n\nexport const balanceLines = new ActionBuilder<StellarActions, 'balanceLines'>(\n 'balanceLines',\n).action(async function (_, accountId: string) {\n const server = new StellarSdk.Horizon.Server(HORIZON_URL);\n const account = await server.loadAccount(accountId);\n\n return account.balances;\n});\n", "/*\n * @see https://namespaces.chainagnostic.org/stellar/README\n */\n\n// if the value neeeds to be change make sure you will update mapCaipNamespaceToLegacyNetworkName as well\nexport const CAIP_NAMESPACE = 'stellar';\nexport const CAIP_STELLAR_CHAIN_ID = 'mainnet';\n\nexport const HORIZON_URL = 'https://horizon.stellar.org';\n", "import { AccountId } from 'caip';\n\nimport { CAIP_NAMESPACE, CAIP_STELLAR_CHAIN_ID } from './constants.js';\n\nexport function formatAddressToCAIP(address: string): string {\n return AccountId.format({\n address,\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: CAIP_STELLAR_CHAIN_ID,\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "6IAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,YAAAC,IAEA,OAAS,iBAAAC,MAAqB,eAC9B,OACE,yCAAAC,EACA,kBAAAC,EACA,0BAAAC,MACK,wBACP,UAAYC,MAAgB,uBCHrB,IAAMC,EAAiB,UACjBC,EAAwB,UAExBC,EAAc,8BDIpB,IAAMC,EAAUC,EAAA,IACrB,IAAIC,EAAyC,SAAS,EACnD,IAAIC,CAAqC,EACzC,OAAOC,CAAc,EACrB,MAAMC,CAAsB,EAJV,WAMVC,EAAe,IAAIJ,EAC9B,cACF,EAAE,OAAO,eAAgBK,EAAGC,EAAmB,CAI7C,OAFgB,MADD,IAAe,UAAQ,OAAOC,CAAW,EAC3B,YAAYD,CAAS,GAEnC,QACjB,CAAC,EEzBD,IAAAE,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,OAAS,aAAAC,MAAiB,OAInB,SAASC,EAAoBC,EAAyB,CAC3D,OAAOC,EAAU,OAAO,CACtB,QAAAD,EACA,QAAS,CACP,UAAWE,EACX,UAAWC,CACb,CACF,CAAC,CACH,CARgBC,EAAAL,EAAA",
|
|
6
|
+
"names": ["builders_exports", "__export", "balanceLines", "connect", "ActionBuilder", "connectAndUpdateStateForSingleNetwork", "intoConnecting", "intoConnectionFinished", "StellarSdk", "CAIP_NAMESPACE", "CAIP_STELLAR_CHAIN_ID", "HORIZON_URL", "connect", "__name", "ActionBuilder", "connectAndUpdateStateForSingleNetwork", "intoConnecting", "intoConnectionFinished", "balanceLines", "_", "accountId", "HORIZON_URL", "utils_exports", "__export", "formatAddressToCAIP", "AccountId", "formatAddressToCAIP", "address", "AccountId", "CAIP_NAMESPACE", "CAIP_STELLAR_CHAIN_ID", "__name"]
|
|
7
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Accounts, AutoImplementedActionsByRecommended, CommonActions } from '@hub3js/std/types';
|
|
2
|
+
import type { Horizon } from '@stellar/stellar-sdk';
|
|
3
|
+
type BalanceLines = Horizon.AccountResponse['balances'];
|
|
4
|
+
export interface StellarActions extends AutoImplementedActionsByRecommended, CommonActions {
|
|
5
|
+
connect: () => Promise<Accounts>;
|
|
6
|
+
canEagerConnect: () => Promise<boolean>;
|
|
7
|
+
balanceLines: (account: string) => Promise<BalanceLines>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,mCAAmC,EACnC,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,KAAK,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACxD,MAAM,WAAW,cACf,SAAQ,mCAAmC,EAAE,aAAa;IAC1D,OAAO,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1D"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ3D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hub3js/stellar",
|
|
3
|
+
"version": "0.0.0-experimental-29a36fc0-20260720",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"source": "./src/mod.ts",
|
|
7
|
+
"main": "./dist/mod.js",
|
|
8
|
+
"typings": "./dist/mod.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/mod.d.ts",
|
|
12
|
+
"default": "./dist/mod.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "yarn run rangutopia library build",
|
|
21
|
+
"ts-check": "tsc --declaration --emitDeclarationOnly -p tsconfig.json",
|
|
22
|
+
"clean": "rimraf dist",
|
|
23
|
+
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
24
|
+
"lint": "eslint \"**/*.{ts,tsx}\"",
|
|
25
|
+
"test": "vitest",
|
|
26
|
+
"coverage": "vitest run --coverage"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@hub3js/core": "^0.0.0-experimental-29a36fc0-20260720"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@hub3js/core": "^0.0.0-experimental-29a36fc0-20260720"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@hub3js/std": "^0.0.0-experimental-29a36fc0-20260720",
|
|
36
|
+
"@stellar/stellar-sdk": "^15.0.1",
|
|
37
|
+
"caip": "^1.1.1",
|
|
38
|
+
"rango-types": "^0.5.0"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/readme.md
ADDED
package/src/builders.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StellarActions } from './types.js';
|
|
2
|
+
|
|
3
|
+
import { ActionBuilder } from '@hub3js/core';
|
|
4
|
+
import {
|
|
5
|
+
connectAndUpdateStateForSingleNetwork,
|
|
6
|
+
intoConnecting,
|
|
7
|
+
intoConnectionFinished,
|
|
8
|
+
} from '@hub3js/std/operators';
|
|
9
|
+
import * as StellarSdk from '@stellar/stellar-sdk';
|
|
10
|
+
|
|
11
|
+
import { HORIZON_URL } from './constants.js';
|
|
12
|
+
|
|
13
|
+
export const connect = () =>
|
|
14
|
+
new ActionBuilder<StellarActions, 'connect'>('connect')
|
|
15
|
+
.and(connectAndUpdateStateForSingleNetwork)
|
|
16
|
+
.before(intoConnecting)
|
|
17
|
+
.after(intoConnectionFinished);
|
|
18
|
+
|
|
19
|
+
export const balanceLines = new ActionBuilder<StellarActions, 'balanceLines'>(
|
|
20
|
+
'balanceLines',
|
|
21
|
+
).action(async function (_, accountId: string) {
|
|
22
|
+
const server = new StellarSdk.Horizon.Server(HORIZON_URL);
|
|
23
|
+
const account = await server.loadAccount(accountId);
|
|
24
|
+
|
|
25
|
+
return account.balances;
|
|
26
|
+
});
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @see https://namespaces.chainagnostic.org/stellar/README
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// if the value neeeds to be change make sure you will update mapCaipNamespaceToLegacyNetworkName as well
|
|
6
|
+
export const CAIP_NAMESPACE = 'stellar';
|
|
7
|
+
export const CAIP_STELLAR_CHAIN_ID = 'mainnet';
|
|
8
|
+
|
|
9
|
+
export const HORIZON_URL = 'https://horizon.stellar.org';
|
package/src/mod.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Accounts,
|
|
3
|
+
AutoImplementedActionsByRecommended,
|
|
4
|
+
CommonActions,
|
|
5
|
+
} from '@hub3js/std/types';
|
|
6
|
+
import type { Horizon } from '@stellar/stellar-sdk';
|
|
7
|
+
|
|
8
|
+
type BalanceLines = Horizon.AccountResponse['balances'];
|
|
9
|
+
export interface StellarActions
|
|
10
|
+
extends AutoImplementedActionsByRecommended, CommonActions {
|
|
11
|
+
connect: () => Promise<Accounts>;
|
|
12
|
+
canEagerConnect: () => Promise<boolean>;
|
|
13
|
+
balanceLines: (account: string) => Promise<BalanceLines>;
|
|
14
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AccountId } from 'caip';
|
|
2
|
+
|
|
3
|
+
import { CAIP_NAMESPACE, CAIP_STELLAR_CHAIN_ID } from './constants.js';
|
|
4
|
+
|
|
5
|
+
export function formatAddressToCAIP(address: string): string {
|
|
6
|
+
return AccountId.format({
|
|
7
|
+
address,
|
|
8
|
+
chainId: {
|
|
9
|
+
namespace: CAIP_NAMESPACE,
|
|
10
|
+
reference: CAIP_STELLAR_CHAIN_ID,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|