Skip to content

Commit acdd472

Browse files
committed
update old algonode.cloud urls,
1 parent c71c576 commit acdd472

File tree

3 files changed

+68
-75
lines changed

3 files changed

+68
-75
lines changed

README.md

+21-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# ![AlgoStack.js](algostack-badge.svg)
22

3-
43
Everything you need to interact with the **Algorand** blockchain, all bundled together to make your life easier. **All modules are optional**, so you make your own compiled stack as small as possible.
54

65
## Table of Contents
@@ -12,15 +11,13 @@ Everything you need to interact with the **Algorand** blockchain, all bundled to
1211
- [📚 Reading blockchain data](/doc/query.md)
1312
- [❌ Common issues](/doc/issues.md)
1413

15-
1614
## 📦 What's in the stack?
15+
1716
- [js-algorand-sdk](https://github.com/algorand/js-algorand-sdk)
1817
- [myalgo-connect](https://github.com/randlabs/myalgo-connect)
1918
- [walletconnect/client](https://github.com/WalletConnect/walletconnect-monorepo)
2019
- [algorand-walletconnect-qrcode-modal](https://github.com/algorand/walletconnect-monorepo)
2120

22-
23-
2421
## ⚡ Getting Started
2522

2623
First, import the main package, and all modules you need. Then initiate your AlgoStack with the desired options and modules.
@@ -29,55 +26,53 @@ First, import the main package, and all modules you need. Then initiate your Alg
2926
const algostack = new AlgoStack(options: OptionsProps, modules: PlugableModules)
3027
```
3128

32-
Example:
29+
Example:
3330

3431
```js
3532
import AlgoStack from 'algostack';
3633
import Client from 'algostack/client';
37-
import Txns from 'algostack/txns';
3834
import Query from 'algostack/query';
35+
import Txns from 'algostack/txns';
3936

4037
const algostack = new AlgoStack(
4138
{
42-
apiUrl: 'https://testnet-api.algonode.cloud',
43-
indexerUrl: 'https://testnet-idx.algonode.cloud',
44-
},
45-
{ Client, Txns, Query }
39+
apiUrl: 'https://testnet-api.4160.nodely.dev',
40+
indexerUrl: 'https://testnet-idx.4160.nodely.dev',
41+
},
42+
{ Client, Txns, Query },
4643
);
4744
```
4845

49-
5046
### ⚙️ Options
47+
5148
```ts
5249
interface OptionsProps {
5350
// Indexer and Node urls used to interact with the blockchain
54-
indexerUrl?: string, // default: 'https://mainnet-idx.algonode.cloud'
55-
apiUrl?: string, // default: 'https://mainnet-api.algonode.cloud'
56-
apiPort?: number,
57-
apiToken?: string,
58-
51+
indexerUrl?: string; // default: 'https://mainnet-idx.4160.nodely.dev'
52+
apiUrl?: string; // default: 'https://mainnet-api.4160.nodely.dev'
53+
apiPort?: number;
54+
apiToken?: string;
5955

6056
// Persist wallet connections, even after refreshing
6157
// Only available in browsers
62-
persistConnection?: boolean // default: true,
63-
storageNamespace?: string // default: 'algostack',
58+
persistConnection?: boolean; // default: true,
59+
storageNamespace?: string; // default: 'algostack',
6460
}
6561
```
6662

67-
6863
### 🔌 Plugable Modules
6964

7065
```ts
7166
interface PlugableModules {
7267
// Connect to Algorand using popular wallets
7368
// Currently available: MyAglo, Pera Wallet
74-
Client?: ClientModule,
75-
76-
// Create, sign, send transactions and wait for confirmation
77-
Txns?: TxnsModule,
69+
Client?: ClientModule;
70+
71+
// Create, sign, send transactions and wait for confirmation
72+
Txns?: TxnsModule;
7873

7974
// Get data from the blockchain
8075
// Currently using the indexers only
81-
Query?: QueryModule,
82-
}
83-
```
76+
Query?: QueryModule;
77+
}
78+
```

src/helpers/encoding.ts

+38-37
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,60 @@
1-
import { Buffer } from 'buffer'
1+
import { Buffer } from 'buffer';
22
import { decodeObj, encodeAddress } from 'algosdk';
3-
import { Encoding } from '../enums.js';
43
import axios from 'axios';
4+
5+
import { Encoding } from '../enums.js';
56
import { isAddress } from './strings.js';
6-
export { decodeAddress, encodeAddress, getApplicationAddress, Transaction } from 'algosdk';
7+
8+
export {
9+
decodeAddress,
10+
encodeAddress,
11+
getApplicationAddress,
12+
Transaction,
13+
} from 'algosdk';
714

815
export interface DecodedB64 {
9-
encoding: Encoding,
10-
original: string,
11-
decoded: Partial<
12-
Record<Encoding, string>
13-
>,
16+
encoding: Encoding;
17+
original: string;
18+
decoded: Partial<Record<Encoding, string>>;
1419
}
1520

1621
/**
1722
* Convert between UTF8 and base64
1823
* ==================================================
1924
*/
2025

21-
export function utf8ToB64 (str: string) {
26+
export function utf8ToB64(str: string) {
2227
return Buffer.from(str).toString('base64');
2328
}
24-
export function hexToB64 (str: string) {
29+
export function hexToB64(str: string) {
2530
return Buffer.from(str.replace(/^0x/, ''), 'hex').toString('base64');
2631
}
27-
export function b64ToUtf8 (str: string) {
32+
export function b64ToUtf8(str: string) {
2833
return Buffer.from(str, 'base64').toString();
2934
}
3035

31-
32-
3336
/**
3437
* Convert object values to strings
3538
* ==================================================
3639
*/
3740
export function objectValuesToString(params: object) {
38-
const obj: {[k:string]: string} = {};
39-
Object.entries(params)
40-
.forEach(([key, value]) => {
41-
obj[key] = String(value);
42-
});
41+
const obj: { [k: string]: string } = {};
42+
Object.entries(params).forEach(([key, value]) => {
43+
obj[key] = String(value);
44+
});
4345
return obj;
4446
}
4547

46-
47-
4848
export async function decompileTeal(b64: string) {
49-
5049
const programBuffer = Buffer.from(b64, 'base64');
5150
const result = await axios({
5251
method: 'post',
53-
url: 'https://mainnet-api.algonode.cloud/v2/teal/disassemble',
52+
url: 'https://mainnet-api.4160.nodely.dev/x2/assetautorank/v2/teal/disassemble',
5453
headers: {
5554
'Content-Type': 'application/x-binary',
5655
},
5756
data: programBuffer,
58-
})
57+
});
5958
// const append = Buffer.from([0xa4, 0x61, 0x70, 0x61, 0x70]);
6059
// const prepend = Buffer.from([ 0x8]);
6160
// const buffer = Buffer.concat([append, programBuffer]);
@@ -64,30 +63,30 @@ export async function decompileTeal(b64: string) {
6463
return result;
6564
}
6665

67-
68-
6966
/**
7067
* Decode base 64
7168
* Check for encoding returning latin chars
7269
* ==================================================
7370
*/
7471
export class B64Decoder {
7572
public readonly original: string;
76-
public readonly parsed: Partial< Record< Encoding, string|number|Record<string, any> > >;
73+
public readonly parsed: Partial<
74+
Record<Encoding, string | number | Record<string, any>>
75+
>;
7776
public encoding: Encoding;
78-
79-
constructor (str: string) {
77+
78+
constructor(str: string) {
8079
this.original = str;
8180
this.encoding = Encoding.B64;
8281
const buffer = Buffer.from(str, 'base64');
83-
const decodedStr = buffer.toString('utf8');
84-
const decodedHex = '0x'+buffer.toString('hex').toUpperCase()
82+
const decodedStr = buffer.toString('utf8');
83+
const decodedHex = '0x' + buffer.toString('hex').toUpperCase();
8584
const decodedNumber = parseInt(decodedHex, 16);
8685
this.parsed = {
8786
[Encoding.B64]: str,
8887
[Encoding.HEX]: decodedHex,
8988
};
90-
89+
9190
// UTF8 - Latin char only
9291
if (/\p{L}+/gu.test(decodedStr)) {
9392
this.parsed[Encoding.UTF8] = decodedStr.replace(/[\x00-\x1F]/g, ' ');
@@ -97,15 +96,17 @@ export class B64Decoder {
9796
// Number
9897
if (!isNaN(decodedNumber) && decodedNumber < Number.MAX_SAFE_INTEGER) {
9998
this.parsed[Encoding.NUMBER] = decodedNumber;
100-
if (!/^[\a-zA-Z0-9\s\.-_]+$/i.test(decodedStr)){
99+
if (!/^[\a-zA-Z0-9\s\.-_]+$/i.test(decodedStr)) {
101100
this.encoding = Encoding.NUMBER;
102-
}
103-
const hexBytesLength = decodedHex.length - 2;
104-
if (hexBytesLength <= 32 && new Date(decodedNumber * 1000).getFullYear() > 2000 ) {
101+
}
102+
const hexBytesLength = decodedHex.length - 2;
103+
if (
104+
hexBytesLength <= 32 &&
105+
new Date(decodedNumber * 1000).getFullYear() > 2000
106+
) {
105107
this.parsed[Encoding.TIMESTAMP] = decodedNumber * 1000;
106108
}
107109
}
108-
109110

110111
// JSON
111112
if (decodedStr.startsWith('{')) {
@@ -133,7 +134,7 @@ export class B64Decoder {
133134
}
134135
}
135136

136-
get decoded () {
137+
get decoded() {
137138
return this.parsed?.[this.encoding];
138139
}
139140
}

src/utils/configs.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
21
/**
32
* All configs available in AlgoStack
43
* ==================================================
54
*/
65
export interface BaseConfigs {}
76

87
export interface GlobalConfigs extends BaseConfigs {
9-
version?: number,
8+
version?: number;
109
// Indexer and Node urls used to interact with the blockchain
11-
indexerUrl?: string,
12-
apiUrl?: string,
13-
apiPort?: number,
14-
apiToken?: string,
15-
autoInit?: boolean,
10+
indexerUrl?: string;
11+
apiUrl?: string;
12+
apiPort?: number;
13+
apiToken?: string;
14+
autoInit?: boolean;
1615
}
1716

18-
1917
/**
2018
* default optionts
2119
* ==================================================
2220
*/
2321
const defaultGlobalConfigs: GlobalConfigs = {
2422
version: 2,
25-
indexerUrl: 'https://mainnet-idx.algonode.cloud',
26-
apiUrl: 'https://mainnet-api.algonode.cloud',
23+
indexerUrl: 'https://mainnet-idx.4160.nodely.dev',
24+
apiUrl: 'https://mainnet-api.4160.nodely.dev',
2725
apiToken: undefined,
2826
apiPort: undefined,
2927
autoInit: true,
30-
}
28+
};
3129

3230
export default defaultGlobalConfigs;
33-

0 commit comments

Comments
 (0)