-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement the new trigger, node, edge structure
- Loading branch information
Showing
26 changed files
with
4,771 additions
and
2,523 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
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
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,20 @@ | ||
package taskengine | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/AvaProtocol/ap-avs/storage" | ||
) | ||
|
||
// Shortcut to initialize a storage at the given path, panic if we cannot create db | ||
func TestMustDB() storage.Storage { | ||
dir, err := os.MkdirTemp("", "aptest") | ||
if err != nil { | ||
panic(err) | ||
} | ||
db, err := storage.NewWithPath(dir) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return db | ||
} |
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,50 @@ | ||
package taskengine | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/AvaProtocol/ap-avs/model" | ||
"github.com/AvaProtocol/ap-avs/storage" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
func TestWalletOwnerReturnTrueForDefaultAddress(t *testing.T) { | ||
smartAddress := common.HexToAddress("0x5Df343de7d99fd64b2479189692C1dAb8f46184a") | ||
|
||
result, err := ValidWalletOwner(nil, &model.User{ | ||
Address: common.HexToAddress("0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5"), | ||
SmartAccountAddress: &smartAddress, | ||
}, common.HexToAddress("0x5Df343de7d99fd64b2479189692C1dAb8f46184a")) | ||
|
||
if !result || err != nil { | ||
t.Errorf("expect true, got false") | ||
} | ||
} | ||
|
||
func TestWalletOwnerReturnTrueForNonDefaultAddress(t *testing.T) { | ||
db := TestMustDB() | ||
defer storage.Destroy(db.(*storage.BadgerStorage)) | ||
|
||
eoa := common.HexToAddress("0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5") | ||
defaultSmartWallet := common.HexToAddress("0x5Df343de7d99fd64b2479189692C1dAb8f46184a") | ||
customSmartWallet := common.HexToAddress("0xdD85693fd14b522a819CC669D6bA388B4FCd158d") | ||
|
||
result, err := ValidWalletOwner(db, &model.User{ | ||
Address: eoa, | ||
SmartAccountAddress: &defaultSmartWallet, | ||
}, customSmartWallet) | ||
if result == true { | ||
t.Errorf("expect 0xdD85693fd14b522a819CC669D6bA388B4FCd158d not owned by 0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5, got true") | ||
} | ||
|
||
// setup wallet binding | ||
db.Set([]byte(WalletStorageKey(eoa, customSmartWallet.Hex())), []byte("1")) | ||
|
||
result, err = ValidWalletOwner(db, &model.User{ | ||
Address: eoa, | ||
SmartAccountAddress: &defaultSmartWallet, | ||
}, customSmartWallet) | ||
if !result || err != nil { | ||
t.Errorf("expect 0xdD85693fd14b522a819CC669D6bA388B4FCd158d owned by 0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5, got false") | ||
} | ||
} |
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,5 @@ | ||
package taskengine | ||
|
||
// The VM is the core component that load the node information and execute them, yield finaly result | ||
type VM struct { | ||
} |
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 |
---|---|---|
@@ -1,4 +1,37 @@ | ||
# Ava Protocol Example | ||
# Ava Protocol Examples | ||
|
||
Example code on how to interact with Ava Protocol RPC server to create and | ||
manage task. | ||
Example codes on how to interact with Ava Protocol RPC server to create and | ||
manage tasks. | ||
|
||
Examples weren't written to be parameterized or extensible. Its only purpose | ||
is to show how to run a specific example, and allow the audience to see | ||
how the code will look like. | ||
|
||
Therefore, the script is harded coded, there is no parameter to provide or anything. | ||
|
||
If you need to change a parameter for a test, edit the code and re-run it. | ||
|
||
# Available example | ||
|
||
## Prepare depedencies | ||
|
||
``` | ||
npm ci | ||
``` | ||
|
||
Then run: | ||
|
||
``` | ||
node example.js | ||
``` | ||
|
||
it will list all available action to run. | ||
|
||
## Setting env | ||
|
||
``` | ||
export env=<development|staging|production> | ||
export PRIVATE_KEY=<any-wallet-private-key> | ||
``` | ||
|
||
The test example using a dummy token which anyone can mint https://sepolia.etherscan.io/address/0x2e8bdb63d09ef989a0018eeb1c47ef84e3e61f7b#writeProxyContract |
Oops, something went wrong.