Skip to content

Commit

Permalink
Merge pull request #6 from Bobinstein/turbo-fix
Browse files Browse the repository at this point in the history
fix(Turbo-Irys): Fixed Irys node issue in Warp when using Turbo
  • Loading branch information
Envoy-VC authored Jan 24, 2024
2 parents 95809a1 + 47c86bc commit c68f44b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Using Turbo Through Irys:
import Irys from '@irys/sdk';

const irys = new Irys({
url: 'https://up.arweave.net',
url: 'https://turbo.ardrive.io',
token: 'matic',
key: 'your-private-key',
});
Expand Down
17 changes: 16 additions & 1 deletion packages/atomic-toolkit/src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,26 @@ class Utilities extends ModuleBase {
throw new Error('Irys is not defined');
}
const url = this.irys.api.config.url.href;

// Checks for Turbo urls being used in Irys
if (
url.includes('up.arweave.net') ||
url.includes('turbo.ardrive.io')
) {
return 'arweave';
}

const node = url?.split('https://')[1]?.split('.irys.xyz')[0];
if (node === 'devnet') {
throw new Error('Only Node1 and Node2 are supported');
}
return node as 'node1' | 'node2';

if (node === 'node1' || node === 'node2') {
return node;
}

// Catch-all error for unexpected URLs
throw new Error('Unrecognized or unsupported URL');
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-toolkit/tests/utils/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Utilities', () => {
});
it('should return cost to upload data using irys through Turbo', async () => {
const irys = new Irys({
url: 'https://up.arweave.net',
url: 'https://turbo.ardrive.io',
token: 'matic',
key: process.env.PRIVATE_KEY,
});
Expand Down

0 comments on commit c68f44b

Please sign in to comment.