-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #459 from arconnectio/staging
ArConnect 1.18.0
- Loading branch information
Showing
25 changed files
with
674 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { PermissionType } from "~applications/permissions"; | ||
import type { ModuleProperties } from "~api/module"; | ||
|
||
const permissions: PermissionType[] = ["ACCESS_TOKENS"]; | ||
|
||
const userTokensModule: ModuleProperties = { | ||
functionName: "userTokens", | ||
permissions | ||
}; | ||
|
||
export default userTokensModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { ModuleFunction } from "~api/background"; | ||
import { ExtensionStorage } from "~utils/storage"; | ||
import { | ||
getAoTokenBalance, | ||
getNativeTokenBalance, | ||
type TokenInfo, | ||
type TokenInfoWithBalance | ||
} from "~tokens/aoTokens/ao"; | ||
import { AO_NATIVE_TOKEN } from "~utils/ao_import"; | ||
|
||
const background: ModuleFunction<TokenInfoWithBalance[] | TokenInfo[]> = async ( | ||
_, | ||
options?: { fetchBalance?: boolean } | ||
) => { | ||
const address = await ExtensionStorage.get("active_address"); | ||
const tokens = (await ExtensionStorage.get<TokenInfo[]>("ao_tokens")) || []; | ||
|
||
if (!options?.fetchBalance) { | ||
return tokens; | ||
} | ||
|
||
const enrichedTokens: TokenInfoWithBalance[] = await Promise.all( | ||
tokens.map(async (token) => { | ||
let balance: string | null = null; | ||
|
||
try { | ||
if (token.processId === AO_NATIVE_TOKEN) { | ||
balance = await getNativeTokenBalance(address); | ||
} else { | ||
const balanceResult = await getAoTokenBalance( | ||
address, | ||
token.processId | ||
); | ||
balance = balanceResult.toString(); | ||
} | ||
} catch (error) { | ||
console.error( | ||
`Error fetching balance for token ${token.Name} (${token.processId}):`, | ||
error | ||
); | ||
} | ||
|
||
return { ...token, balance }; | ||
}) | ||
); | ||
|
||
return enrichedTokens; | ||
}; | ||
|
||
export default background; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { ModuleFunction } from "~api/module"; | ||
|
||
// no need to transform anything in the foreground | ||
const foreground: ModuleFunction<void> = () => {}; | ||
|
||
export default foreground; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.