Skip to content

Commit

Permalink
feat(keyAutoAdd): support interledger.cards (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Nov 6, 2024
1 parent ef29a42 commit 64ce8a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/background/services/keyAutoAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export function walletAddressToProvider(walletAddress: WalletAddress): {
return {
url: 'https://wallet.interledger-test.dev/settings/developer-keys',
};
case 'ilp.interledger.cards':
return {
url: 'https://wallet.interledger.cards/settings/developer-keys',
};
case 'eu1.fynbos.me':
return { url: 'https://eu1.fynbos.dev/settings/keys' };
case 'fynbos.me':
Expand Down
9 changes: 7 additions & 2 deletions src/content/keyAutoAdd/testWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ type AccountDetails = {
};
};

const API_ORIGIN =
location.host === 'wallet.interledger.cards'
? 'https://api.interledger.cards'
: `https://api.${location.host}`;

const waitForLogin: Run<void> = async (
{ keyAddUrl },
{ skip, setNotificationSize },
Expand Down Expand Up @@ -125,7 +130,7 @@ const findWallet: Run<{ accountId: string; walletId: string }> = async (

const addKey: Run<void> = async ({ publicKey, nickName }, { output }) => {
const { accountId, walletId } = output(findWallet);
const url = `https://api.${location.host}/accounts/${accountId}/wallet-addresses/${walletId}/upload-key`;
const url = `${API_ORIGIN}/accounts/${accountId}/wallet-addresses/${walletId}/upload-key`;
const res = await fetch(url, {
method: 'POST',
headers: {
Expand All @@ -147,7 +152,7 @@ const addKey: Run<void> = async ({ publicKey, nickName }, { output }) => {

// region: Helpers
async function revokeKey(accountId: string, walletId: string, keyId: string) {
const url = `https://api.${location.host}/accounts/${accountId}/wallet-addresses/${walletId}/${keyId}/revoke-key/`;
const url = `${API_ORIGIN}/accounts/${accountId}/wallet-addresses/${walletId}/${keyId}/revoke-key/`;
const res = await fetch(url, {
method: 'PATCH',
headers: {
Expand Down
5 changes: 4 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"all_frames": true
},
{
"matches": ["https://wallet.interledger-test.dev/*"],
"matches": [
"https://wallet.interledger-test.dev/*",
"https://wallet.interledger.cards/*"
],
"js": ["content/keyAutoAdd/testWallet.js"],
"run_at": "document_end"
},
Expand Down

0 comments on commit 64ce8a5

Please sign in to comment.