forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ELIZAAI-21-create-readme-for-generating-access-token #20
Open
rozekmichal
wants to merge
11
commits into
develop
Choose a base branch
from
ELIZAAAI-21-create-readme-for-generating-oauth-token
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a9fecd3
feat: ibc transfer action
KacperKoza343 6a929a1
refactor: remove redundant services and use skipClient
KacperKoza343 b3d8b05
update: eliza package import
KacperKoza343 2c4b037
feat: add bridge data fetcher and update tests
KacperKoza343 8e467ff
update: add IBC transfer action to README
KacperKoza343 63acdd4
refactor: make bridge data fetcher reusable across the project
KacperKoza343 907ed03
fix: update similes for ibc transfer action
KacperKoza343 64e6cb2
fix: update toAddress in ibc transfer
KacperKoza343 3504675
Merge branch 'develop' into ELIZAAI-17-cross-chain-bridging-ibc-or-ex…
KacperKoza343 480e4f6
Merge pull request #14 from blockydevs/ELIZAAI-17-cross-chain-bridgin…
KacperKoza343 8d5b3a3
feat: add readme for access token generating
rozekmichal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# How to Generate an Access Token Manually Using the LinkedIn Developer Portal | ||
|
||
The LinkedIn access token is essential for enabling API calls on behalf of a user. It allows your application to interact with LinkedIn's API to perform actions such as posting updates, accessing user profiles, and managing LinkedIn pages. The following instructions will guide you through the process of generating this token. | ||
|
||
## Step 1: Create a New Application | ||
|
||
1. Navigate to the [LinkedIn Developer Portal](https://developer.linkedin.com/). | ||
2. Click the **Create app** button. | ||
3. Fill in the **App name** field. | ||
4. Specify a **LinkedIn Page** (either select an existing page or create a new one). | ||
5. Upload a **logo** from your local device. | ||
6. Agree to the terms and conditions by selecting **I have read and agree to these terms**. | ||
7. Complete the process by clicking the **Create app** button. | ||
|
||
## Step 2: Configure Your Linkedin Application | ||
|
||
1. Navigate to the **Products** tab in your application. | ||
2. Under **OAuth Permissions**, select the following scopes: | ||
- **Sign In with LinkedIn using OpenID Connect** | ||
- **Share on LinkedIn** | ||
|
||
## Step 3: Generate an Access Token | ||
|
||
1. Open the **Auth** tab in your application. | ||
2. Click on the **OAuth 2.0 tools** link (you can also navigate via **Docs and tools > OAuth Token Tools** in the navigation bar). | ||
3. Press **Create token** to start the process. | ||
4. Ensure the **OAuth flow** is set to **Member authorization code (3-legged)**. | ||
5. Under **Select scopes**, check the boxes for: | ||
- `openid` | ||
- `profile` | ||
- `w_member_social` | ||
6. Click the **Request access token** button. | ||
7. Log in using your LinkedIn credentials and click **Sign In**. | ||
8. Grant your application the requested permissions by selecting **Allow**. | ||
9. After successful authorization, your **access token** will be displayed and is ready for use. | ||
|
||
### Resolving Common Issues | ||
|
||
If you encounter the error: | ||
|
||
> "We can’t verify the authenticity of your request because the state parameter was modified." | ||
|
||
This may indicate that your browser is blocking the request. To resolve: | ||
|
||
- Disable all browser extensions temporarily. | ||
- Try generating the token in another browser (e.g., Google Chrome). | ||
|
||
``` | ||
Important! Be aware that some browsers, such as Brave, have built-in protections that might block token generation. | ||
``` | ||
|
||
## Important Notes | ||
|
||
- The access token is valid for **2 months**. After expiration, you must repeat the steps above to generate a new token. | ||
- If the token does not have all the required permissions, regenerate it and ensure the correct scopes are selected. | ||
- Generating the access token automatically updates the **Authorized redirect URLs for your app** field in your application. | ||
|
||
### What Is a Redirect URL? | ||
|
||
A **redirect URL** is the URI where users are sent after authorization. It must match one of the redirect URLs defined in your application configuration. | ||
|
||
For more detailed information, visit Microsoft's official documentation on the [Authorization Code Flow (3-legged OAuth)](https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?tabs=HTTPS1). |
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
226 changes: 226 additions & 0 deletions
226
packages/plugin-cosmos/src/actions/ibc-transfer/index.ts
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,226 @@ | ||
import { | ||
composeContext, | ||
generateObjectDeprecated, | ||
HandlerCallback, | ||
IAgentRuntime, | ||
Memory, | ||
ModelClass, | ||
State, | ||
} from "@elizaos/core"; | ||
import { initWalletChainsData } from "../../providers/wallet/utils"; | ||
import { | ||
cosmosIBCTransferTemplate, | ||
cosmosTransferTemplate, | ||
} from "../../templates"; | ||
import type { | ||
ICosmosPluginOptions, | ||
ICosmosWalletChains, | ||
} from "../../shared/interfaces"; | ||
import { IBCTransferActionParams } from "./types"; | ||
import { IBCTransferAction } from "./services/ibc-transfer-action-service"; | ||
import { bridgeDenomProvider } from "./services/bridge-denom-provider"; | ||
|
||
export const createIBCTransferAction = ( | ||
pluginOptions: ICosmosPluginOptions | ||
) => ({ | ||
name: "COSMOS_IBC_TRANSFER", | ||
description: "Transfer tokens between addresses on cosmos chains", | ||
handler: async ( | ||
_runtime: IAgentRuntime, | ||
_message: Memory, | ||
state: State, | ||
_options: { [key: string]: unknown }, | ||
_callback?: HandlerCallback | ||
) => { | ||
const cosmosIBCTransferContext = composeContext({ | ||
state: state, | ||
template: cosmosIBCTransferTemplate, | ||
templatingEngine: "handlebars", | ||
}); | ||
|
||
const cosmosIBCTransferContent = await generateObjectDeprecated({ | ||
runtime: _runtime, | ||
context: cosmosIBCTransferContext, | ||
modelClass: ModelClass.SMALL, | ||
}); | ||
|
||
const paramOptions: IBCTransferActionParams = { | ||
chainName: cosmosIBCTransferContent.chainName, | ||
symbol: cosmosIBCTransferContent.symbol, | ||
amount: cosmosIBCTransferContent.amount, | ||
toAddress: cosmosIBCTransferContent.toAddress, | ||
targetChainName: cosmosIBCTransferContent.targetChainName, | ||
}; | ||
|
||
try { | ||
const walletProvider: ICosmosWalletChains = | ||
await initWalletChainsData(_runtime); | ||
|
||
const action = new IBCTransferAction(walletProvider); | ||
|
||
const customAssets = (pluginOptions?.customChainData ?? []).map( | ||
(chainData) => chainData.assets | ||
); | ||
|
||
const transferResp = await action.execute( | ||
paramOptions, | ||
bridgeDenomProvider, | ||
customAssets | ||
); | ||
|
||
if (_callback) { | ||
await _callback({ | ||
text: `Successfully transferred ${paramOptions.amount} tokens from ${paramOptions.chainName} to ${paramOptions.toAddress} on ${paramOptions.targetChainName}\nTransaction Hash: ${transferResp.txHash}`, | ||
content: { | ||
success: true, | ||
hash: transferResp.txHash, | ||
amount: paramOptions.amount, | ||
recipient: transferResp.to, | ||
fromChain: paramOptions.chainName, | ||
toChain: paramOptions.targetChainName, | ||
}, | ||
}); | ||
|
||
const newMemory: Memory = { | ||
userId: _message.agentId, | ||
agentId: _message.agentId, | ||
roomId: _message.roomId, | ||
content: { | ||
text: `Transaction ${paramOptions.amount} ${paramOptions.symbol} to address ${paramOptions.toAddress} from chain ${paramOptions.chainName} to ${paramOptions.targetChainName} was successfully transferred. Tx hash: ${transferResp.txHash}`, | ||
}, | ||
}; | ||
|
||
await _runtime.messageManager.createMemory(newMemory); | ||
} | ||
return true; | ||
} catch (error) { | ||
console.error("Error during ibc token transfer:", error); | ||
|
||
if (_callback) { | ||
await _callback({ | ||
text: `Error ibc transferring tokens: ${error.message}`, | ||
content: { error: error.message }, | ||
}); | ||
} | ||
|
||
const newMemory: Memory = { | ||
userId: _message.agentId, | ||
agentId: _message.agentId, | ||
roomId: _message.roomId, | ||
content: { | ||
text: `Transaction ${paramOptions.amount} ${paramOptions.symbol} to address ${paramOptions.toAddress} on chain ${paramOptions.chainName} to ${paramOptions.targetChainName} was unsuccessful.`, | ||
}, | ||
}; | ||
|
||
await _runtime.messageManager.createMemory(newMemory); | ||
|
||
return false; | ||
} | ||
}, | ||
template: cosmosTransferTemplate, | ||
validate: async (runtime: IAgentRuntime) => { | ||
const mnemonic = runtime.getSetting("COSMOS_RECOVERY_PHRASE"); | ||
const availableChains = runtime.getSetting("COSMOS_AVAILABLE_CHAINS"); | ||
const availableChainsArray = availableChains?.split(","); | ||
|
||
return !(mnemonic && availableChains && availableChainsArray.length); | ||
}, | ||
examples: [ | ||
[ | ||
{ | ||
user: "{{user1}}", | ||
content: { | ||
text: "Make an IBC transfer {{0.0001 ATOM}} to {{osmosis1pcnw46km8m5amvf7jlk2ks5std75k73aralhcf}} from {{cosmoshub}} to {{osmosis}}", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user2}}", | ||
content: { | ||
text: "Do you confirm the IBC transfer action?", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user1}}", | ||
content: { | ||
text: "Yes", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user2}}", | ||
content: { | ||
text: "", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
user: "{{user1}}", | ||
content: { | ||
text: "Send {{50 OSMO}} to {{juno13248w8dtnn07sxc3gq4l3ts4rvfyat6f4qkdd6}} from {{osmosis}} to {{juno}}", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user2}}", | ||
content: { | ||
text: "Do you confirm the IBC transfer action?", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user1}}", | ||
content: { | ||
text: "Yes", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user2}}", | ||
content: { | ||
text: "", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
user: "{{user1}}", | ||
content: { | ||
text: "Transfer {{0.005 JUNO}} from {{juno}} to {{cosmos1n0xv7z2pkl4eppnm7g2rqhe2q8q6v69h7w93fc}} on {{cosmoshub}}", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user2}}", | ||
content: { | ||
text: "Do you confirm the IBC transfer action?", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user1}}", | ||
content: { | ||
text: "Yes", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
{ | ||
user: "{{user2}}", | ||
content: { | ||
text: "", | ||
action: "COSMOS_IBC_TRANSFER", | ||
}, | ||
}, | ||
], | ||
], | ||
similes: [ | ||
"COSMOS_BRIDGE_TOKEN", | ||
"COSMOS_IBC_SEND_TOKEN", | ||
"COSMOS_TOKEN_IBC_TRANSFER", | ||
"COSMOS_MOVE_IBC_TOKENS", | ||
], | ||
}); |
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,9 @@ | ||
import { z } from "zod"; | ||
|
||
export const IBCTransferParamsSchema = z.object({ | ||
chainName: z.string(), | ||
symbol: z.string(), | ||
amount: z.string(), | ||
toAddress: z.string(), | ||
targetChainName: z.string(), | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/plugin-cosmos/src/actions/ibc-transfer/services/bridge-denom-provider.ts
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,27 @@ | ||
import { IDenomProvider } from "../../../shared/interfaces"; | ||
import { SkipApiAssetsFromSourceFetcher } from "../../../shared/services/skip-api/assets-from-source-fetcher/skip-api-assets-from-source-fetcher"; | ||
|
||
export const bridgeDenomProvider: IDenomProvider = async ( | ||
sourceAssetDenom: string, | ||
sourceAssetChainId: string, | ||
destChainId: string | ||
) => { | ||
const skipApiAssetsFromSourceFetcher = | ||
SkipApiAssetsFromSourceFetcher.getInstance(); | ||
const bridgeData = await skipApiAssetsFromSourceFetcher.fetch( | ||
sourceAssetDenom, | ||
sourceAssetChainId | ||
); | ||
|
||
const ibcAssetData = bridgeData.dest_assets[destChainId]?.assets?.find( | ||
({ origin_denom }) => origin_denom === sourceAssetDenom | ||
); | ||
|
||
if (!ibcAssetData.denom) { | ||
throw new Error("No IBC asset data"); | ||
} | ||
|
||
return { | ||
denom: ibcAssetData.denom, | ||
}; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth to mention that this will result in getting an access token for interacting with User Account which will allow posting only as a Person not as a Company.