-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81f46c6
commit 3c9db8c
Showing
11 changed files
with
135 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
[features] | ||
seeds = false | ||
skip-lint = false | ||
|
||
[programs.devnet] | ||
sube_crypto = "2A65abYAkY9pBw6rAZyu5q4uwLdjyjd66WWwazewHPmv" | ||
sube_crypto = "CPxMkDjjywp6FQdKenw92zVJEDc6TVFEXhG7yLc7Xw4N" | ||
|
||
[registry] | ||
url = "https://api.apr.dev" | ||
|
||
[provider] | ||
cluster = "devnet" | ||
cluster = "Devnet" | ||
wallet = "/home/mateo/.config/solana/id.json" | ||
|
||
[scripts] | ||
[scripts] | ||
init_bus_line = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/init_bus_line.ts" | ||
trip = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/trip.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
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 @@ | ||
{ | ||
"scripts": { | ||
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", | ||
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" | ||
}, | ||
"dependencies": { | ||
"@coral-xyz/anchor": "^0.29.0", | ||
"yarn": "^1.22.21" | ||
}, | ||
"devDependencies": { | ||
"@types/bn.js": "^5.1.0", | ||
"@types/chai": "^4.3.0", | ||
"@types/mocha": "^9.0.0", | ||
"chai": "^4.3.4", | ||
"mocha": "^9.2.2", | ||
"prettier": "^2.6.2", | ||
"ts-mocha": "^10.0.0", | ||
"typescript": "^4.3.5" | ||
} | ||
} |
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,6 +1,6 @@ | ||
[package] | ||
name = "sube_crypto" | ||
version = "1.0.0" | ||
version = "1.0.1" | ||
description = "." | ||
edition = "2021" | ||
|
||
|
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 |
---|---|---|
@@ -1,12 +1,27 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
const ANCHOR_BUFFER: usize = 8; | ||
pub const MAX_KM: u8 = 4; //(0,1,2,3,4) | ||
|
||
#[account] | ||
pub struct SubeAdminAccount { | ||
pub authority: Pubkey, // 32 | ||
pub bump_original: u8, // 1 | ||
pub prices: Vec<u64>, // 4 + 8 * 5 | ||
pub prices: Vec<u64>, // 4 + [8 * 5] | ||
} | ||
|
||
impl SubeAdminAccount { | ||
pub const SIZE: usize = 32 + 1 + 4 + (8 * 5); | ||
pub const SIZE: usize = 32 + 1 + 4 + (8 * 5) + ANCHOR_BUFFER; | ||
|
||
pub fn set_authority(&mut self, authority: Pubkey) { | ||
self.authority = authority; | ||
} | ||
|
||
pub fn set_bump_original(&mut self, bump: u8) { | ||
self.bump_original = bump; | ||
} | ||
|
||
pub fn set_prices(&mut self, to3km: u64, to6km: u64, to12km: u64, to27km: u64, more27km: u64) { | ||
self.prices = [to3km, to6km, to12km, to27km, more27km].to_vec(); | ||
} | ||
} |
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,35 @@ | ||
import * as anchor from "@coral-xyz/anchor"; | ||
import { Program } from "@coral-xyz/anchor"; | ||
import { SubeCrypto } from "../target/types/sube_crypto"; | ||
import { SystemProgram, PublicKey } from "@solana/web3.js"; | ||
|
||
describe("Register a business", () => { | ||
const provider = anchor.AnchorProvider.env(); | ||
anchor.setProvider(provider); | ||
const payer = provider.wallet as anchor.Wallet; | ||
const program = anchor.workspace.SubeCrypto as Program<SubeCrypto>; | ||
const programId = program.programId; | ||
|
||
it("Is initialized!", async () => { | ||
const sube = PublicKey.findProgramAddressSync( | ||
[payer.publicKey.toBuffer()], | ||
programId | ||
)[0]; | ||
|
||
const tx = await program.methods | ||
.initializeBus( | ||
new anchor.BN(2), | ||
new anchor.BN(5), | ||
new anchor.BN(7), | ||
new anchor.BN(12), | ||
new anchor.BN(23) | ||
) | ||
.accounts({ | ||
sube: sube, | ||
signer: payer.publicKey, | ||
systemProgram: SystemProgram.programId, | ||
}) | ||
.rpc(); | ||
console.log("Transaction signature", tx); | ||
}); | ||
}); |
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,32 @@ | ||
import * as anchor from "@coral-xyz/anchor"; | ||
import { Program } from "@coral-xyz/anchor"; | ||
import { SubeCrypto } from "../target/types/sube_crypto"; | ||
import { SystemProgram, PublicKey } from "@solana/web3.js"; | ||
|
||
describe("Register a business", () => { | ||
const provider = anchor.AnchorProvider.env(); | ||
anchor.setProvider(provider); | ||
const payer = provider.wallet as anchor.Wallet; | ||
const program = anchor.workspace.SubeCrypto as Program<SubeCrypto>; | ||
const programId = program.programId; | ||
|
||
it("Is initialized!", async () => { | ||
const sube = PublicKey.findProgramAddressSync( | ||
[payer.publicKey.toBuffer()], | ||
programId | ||
)[0]; | ||
|
||
const tx = await program.methods | ||
.takeTrip( | ||
2, | ||
) | ||
.accounts({ | ||
sube: sube, | ||
from: payer.publicKey, | ||
to: payer.publicKey, | ||
systemProgram: SystemProgram.programId, | ||
}) | ||
.rpc(); | ||
console.log("Transaction signature", tx); | ||
}); | ||
}); |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": ["mocha", "chai"], | ||
"typeRoots": ["./node_modules/@types"], | ||
"lib": ["es2015"], | ||
"module": "commonjs", | ||
"target": "es6", | ||
"esModuleInterop": true | ||
} | ||
} | ||
|