-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
several new data sources added with updated documentation and resourc…
…e level descriptions
- Loading branch information
Showing
20 changed files
with
503 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "solana_recent_blockhash Data Source - terraform-provider-solana" | ||
subcategory: "" | ||
description: |- | ||
Retrieves a recent block hash from the ledger and the associated cost in lamports per signature on a new transaction for that block | ||
--- | ||
|
||
# solana_recent_blockhash (Data Source) | ||
|
||
Retrieves a recent block hash from the ledger and the associated cost in lamports per signature on a new transaction for that block | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- **id** (String) The ID of this resource. | ||
|
||
### Read-Only | ||
|
||
- **blockhash** (String) Base-58 encoded hash string of the block | ||
- **lamports_per_signature** (Number) The lamports cost per signature of the block | ||
|
||
|
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,30 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "solana_rent_exemption_cost Data Source - terraform-provider-solana" | ||
subcategory: "" | ||
description: |- | ||
Provides the minimum balance required to make an account rent exempt in lamports | ||
--- | ||
|
||
# solana_rent_exemption_cost (Data Source) | ||
|
||
Provides the minimum balance required to make an account rent exempt in lamports | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- **data_length** (Number) The length of the data stored in the account | ||
|
||
### Optional | ||
|
||
- **id** (String) The ID of this resource. | ||
|
||
### Read-Only | ||
|
||
- **lamports** (Number) The calculated minimum cost of rent exemption for the account size | ||
|
||
|
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,28 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "solana_supply Data Source - terraform-provider-solana" | ||
subcategory: "" | ||
description: |- | ||
Provides information about the current supply on the network | ||
--- | ||
|
||
# solana_supply (Data Source) | ||
|
||
Provides information about the current supply on the network | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- **id** (String) The ID of this resource. | ||
|
||
### Read-Only | ||
|
||
- **circulating** (Number) Circulating supply in lamports | ||
- **non_circulating** (Number) Non-circulating supply in lamports | ||
- **total** (Number) Total supply of lamports | ||
|
||
|
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 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "solana_version Data Source - terraform-provider-solana" | ||
subcategory: "" | ||
description: |- | ||
Provides the current Solana software version running on the network node | ||
--- | ||
|
||
# solana_version (Data Source) | ||
|
||
Provides the current Solana software version running on the network node | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- **id** (String) The ID of this resource. | ||
|
||
### Read-Only | ||
|
||
- **feature_set** (Number) A unique identifier of the current software's feature set | ||
- **solana_core** (String) Software version of `solana-core` running on the node | ||
|
||
|
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,42 @@ | ||
package solana | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/gagliardetto/solana-go/rpc" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceRecentBlockhash() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Retrieves a recent block hash from the ledger and the associated cost in lamports per signature on a new transaction for that block", | ||
Read: dataSourceRecentBlockhashRead, | ||
Schema: map[string]*schema.Schema{ | ||
"blockhash": { | ||
Type: schema.TypeString, | ||
Description: "Base-58 encoded hash string of the block", | ||
Computed: true, | ||
}, | ||
"lamports_per_signature": { | ||
Type: schema.TypeInt, | ||
Description: "The lamports cost per signature of the block", | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceRecentBlockhashRead(d *schema.ResourceData, meta interface{}) error { | ||
client := meta.(*providerConfig).rpcClient | ||
|
||
res, err := client.GetRecentBlockhash(context.Background(), rpc.CommitmentRecent) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
d.SetId(fmt.Sprintf("recent_blockhash:%s", res.Value.Blockhash.String())) | ||
d.Set("blockhash", res.Value.Blockhash.String()) | ||
d.Set("lamports_per_signature", uint64(res.Value.FeeCalculator.LamportsPerSignature)) | ||
return nil | ||
} |
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,48 @@ | ||
package solana | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
) | ||
|
||
const ( | ||
testRecentBlockhashDataConfig = ` | ||
provider "solana" { | ||
endpoint = "https://api.testnet.solana.com" | ||
} | ||
data "solana_recent_blockhash" "test" {} | ||
` | ||
) | ||
|
||
func TestAccRecentBlockhashDataSource(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testRecentBlockhashDataConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
testRecentBlockhashDataSucceeds("data.solana_recent_blockhash.test"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testRecentBlockhashDataSucceeds(name string) resource.TestCheckFunc { | ||
return func(state *terraform.State) error { | ||
val, ok := state.RootModule().Resources[name] | ||
if !ok { | ||
return fmt.Errorf("Recent Blockhash Failure: %s not found", name) | ||
} | ||
|
||
if val.Primary.ID == "" { | ||
return fmt.Errorf("Recent Blockhash Failure: ID was not set") | ||
} | ||
|
||
return nil | ||
} | ||
} |
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,42 @@ | ||
package solana | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/gagliardetto/solana-go/rpc" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceRentExemptionCost() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Provides the minimum balance required to make an account rent exempt in lamports", | ||
Read: dataSourceRentExemptionCostRead, | ||
Schema: map[string]*schema.Schema{ | ||
"data_length": { | ||
Type: schema.TypeInt, | ||
Description: "The length of the data stored in the account", | ||
Required: true, | ||
}, | ||
"lamports": { | ||
Type: schema.TypeInt, | ||
Description: "The calculated minimum cost of rent exemption for the account size", | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceRentExemptionCostRead(d *schema.ResourceData, meta interface{}) error { | ||
client := meta.(*providerConfig).rpcClient | ||
|
||
dataLength := d.Get("data_length").(int) | ||
res, err := client.GetMinimumBalanceForRentExemption(context.Background(), dataLength, rpc.CommitmentRecent) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
d.SetId(fmt.Sprintf("rent_exemption_cost:%d", dataLength)) | ||
d.Set("lamports", res) | ||
return nil | ||
} |
Oops, something went wrong.